summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/global/qglobal.h5
-rw-r--r--src/corelib/tools/qstring.h6
2 files changed, 9 insertions, 2 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 33885021ba..e31d4d9ad7 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -747,12 +747,13 @@ Q_CORE_EXPORT Q_DECL_CONST_FUNCTION bool qSharedBuild() Q_DECL_NOTHROW;
# define QT_DEBUG
#endif
+// QtPrivate::asString defined in qstring.h
#ifndef qPrintable
-# define qPrintable(string) QString(string).toLocal8Bit().constData()
+# define qPrintable(string) QtPrivate::asString(string).toLocal8Bit().constData()
#endif
#ifndef qUtf8Printable
-# define qUtf8Printable(string) QString(string).toUtf8().constData()
+# define qUtf8Printable(string) QtPrivate::asString(string).toUtf8().constData()
#endif
/*
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index 0138ae4098..b8f4d49831 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -1857,6 +1857,12 @@ QT_DEPRECATED inline QString escape(const QString &plain) {
#endif
}
+namespace QtPrivate {
+// used by qPrintable() and qUtf8Printable() macros
+inline const QString &asString(const QString &s) { return s; }
+inline QString &&asString(QString &&s) { return std::move(s); }
+}
+
QT_END_NAMESPACE
#if defined(QT_USE_FAST_OPERATOR_PLUS) || defined(QT_USE_QSTRINGBUILDER)