diff options
Diffstat (limited to 'src')
67 files changed, 453 insertions, 378 deletions
diff --git a/src/concurrent/qfutureinterface_p.h b/src/concurrent/qfutureinterface_p.h index 3a73f846ac..b985e31ab6 100644 --- a/src/concurrent/qfutureinterface_p.h +++ b/src/concurrent/qfutureinterface_p.h @@ -80,7 +80,7 @@ public: QFutureCallOutEvent() : QEvent(QEvent::FutureCallOut), callOutType(CallOutType(0)), index1(-1), index2(-1) { } - QFutureCallOutEvent(CallOutType callOutType, int index1 = -1) + explicit QFutureCallOutEvent(CallOutType callOutType, int index1 = -1) : QEvent(QEvent::FutureCallOut), callOutType(callOutType), index1(index1), index2(-1) { } QFutureCallOutEvent(CallOutType callOutType, int index1, int index2) diff --git a/src/corelib/arch/qatomic_gcc.h b/src/corelib/arch/qatomic_gcc.h index 225a7809eb..9edb74fa73 100644 --- a/src/corelib/arch/qatomic_gcc.h +++ b/src/corelib/arch/qatomic_gcc.h @@ -84,7 +84,7 @@ template <typename T> struct QAtomicOps: QGenericAtomicOps<QAtomicOps<T> > typedef T Type; #ifndef __ia64__ - static T loadAcquire(T &_q_value) + static T loadAcquire(const T &_q_value) { T tmp = _q_value; __sync_synchronize(); diff --git a/src/corelib/arch/qatomic_ia64.h b/src/corelib/arch/qatomic_ia64.h index d82ad12223..5108751f2a 100644 --- a/src/corelib/arch/qatomic_ia64.h +++ b/src/corelib/arch/qatomic_ia64.h @@ -143,9 +143,9 @@ template <int size> struct QBasicAtomicOps: QGenericAtomicOps<QBasicAtomicOps<si static void orderedMemoryFence(); template <typename T> static inline - T loadAcquire(T &_q_value) + T loadAcquire(const T &_q_value) { - return *static_cast<volatile T *>(&_q_value); + return *static_cast<const volatile T *>(&_q_value); } template <typename T> static inline diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp index 4cfdfe5966..f6f0cd8699 100644 --- a/src/corelib/codecs/qtextcodec.cpp +++ b/src/corelib/codecs/qtextcodec.cpp @@ -111,7 +111,7 @@ static bool qisalnum(register char c) static bool nameMatch(const QByteArray &name, const QByteArray &test) { // if they're the same, return a perfect score - if (qstricmp(name, test) == 0) + if (qstricmp(name.constData(), test.constData()) == 0) return true; const char *n = name.constData(); @@ -510,7 +510,7 @@ static QTextCodec * ru_RU_hack(const char * i) { koi8r, latin5, i); } #if !defined(QT_NO_SETLOCALE) - setlocale(LC_CTYPE, origlocale); + setlocale(LC_CTYPE, origlocale.constData()); #endif return ru_RU_codec; @@ -648,7 +648,7 @@ static void setupLocaleMapper() else if (try_locale_list(pt_154locales, lang)) localeMapper = QTextCodec::codecForName("PT 154"); else if (try_locale_list(probably_koi8_rlocales, lang)) - localeMapper = ru_RU_hack(lang); + localeMapper = ru_RU_hack(lang.constData()); } } diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 5fbc8cdd19..99328d52ac 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -578,16 +578,6 @@ class QDataStream; # else # define Q_SVG_EXPORT Q_DECL_IMPORT # endif -# if defined(QT_BUILD_QTQUICK1_LIB) -# define Q_QTQUICK1_EXPORT Q_DECL_EXPORT -# else -# define Q_QTQUICK1_EXPORT Q_DECL_IMPORT -# endif -# if defined(QT_BUILD_DECLARATIVE_LIB) -# define Q_DECLARATIVE_EXPORT Q_DECL_EXPORT -# else -# define Q_DECLARATIVE_EXPORT Q_DECL_IMPORT -# endif # if defined(QT_BUILD_OPENGL_LIB) # define Q_OPENGL_EXPORT Q_DECL_EXPORT # else @@ -648,8 +638,6 @@ class QDataStream; # define Q_SQL_EXPORT Q_DECL_IMPORT # define Q_NETWORK_EXPORT Q_DECL_IMPORT # define Q_SVG_EXPORT Q_DECL_IMPORT -# define Q_DECLARATIVE_EXPORT Q_DECL_IMPORT -# define Q_QTQUICK1_EXPORT Q_DECL_IMPORT # define Q_CANVAS_EXPORT Q_DECL_IMPORT # define Q_OPENGL_EXPORT Q_DECL_IMPORT # define Q_MULTIMEDIA_EXPORT Q_DECL_IMPORT @@ -682,8 +670,6 @@ class QDataStream; # define Q_SQL_EXPORT Q_DECL_EXPORT # define Q_NETWORK_EXPORT Q_DECL_EXPORT # define Q_SVG_EXPORT Q_DECL_EXPORT -# define Q_DECLARATIVE_EXPORT Q_DECL_EXPORT -# define Q_QTQUICK1_EXPORT Q_DECL_EXPORT # define Q_OPENGL_EXPORT Q_DECL_EXPORT # define Q_MULTIMEDIA_EXPORT Q_DECL_EXPORT # define Q_OPENVG_EXPORT Q_DECL_EXPORT @@ -702,8 +688,6 @@ class QDataStream; # define Q_SQL_EXPORT # define Q_NETWORK_EXPORT # define Q_SVG_EXPORT -# define Q_DECLARATIVE_EXPORT -# define Q_QTQUICK1_EXPORT # define Q_OPENGL_EXPORT # define Q_MULTIMEDIA_EXPORT # define Q_OPENVG_EXPORT diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index c871675334..4caacece2d 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -46,11 +46,7 @@ #include "qlibraryinfo.h" #include "qscopedpointer.h" -#if defined(QT_BUILD_QMAKE) || defined(QT_BOOTSTRAPPED) -# define BOOTSTRAPPING -#endif - -#ifdef BOOTSTRAPPING +#ifdef QT_BUILD_QMAKE QT_BEGIN_NAMESPACE extern QString qmake_libraryInfoFile(); QT_END_NAMESPACE @@ -97,7 +93,7 @@ public: QLibrarySettings::QLibrarySettings() : settings(QLibraryInfoPrivate::findConfiguration()) { -#ifndef BOOTSTRAPPING +#ifndef QT_BUILD_QMAKE qAddPostRoutine(QLibraryInfoPrivate::cleanup); #endif } @@ -105,7 +101,7 @@ QLibrarySettings::QLibrarySettings() QSettings *QLibraryInfoPrivate::findConfiguration() { QString qtconfig = QLatin1String(":/qt/etc/qt.conf"); -#ifdef BOOTSTRAPPING +#ifdef QT_BUILD_QMAKE if(!QFile::exists(qtconfig)) qtconfig = qmake_libraryInfoFile(); #else @@ -152,6 +148,8 @@ QSettings *QLibraryInfoPrivate::findConfiguration() \sa QSysInfo, {Using qt.conf} */ +#ifndef QT_BUILD_QMAKE + /*! \internal You cannot create a QLibraryInfo, instead only the static functions are available to query @@ -214,135 +212,82 @@ QLibraryInfo::isDebugBuild() return false; } +#endif // QT_BUILD_QMAKE + +static const struct { + char key[14], value[13]; +} qtConfEntries[] = { + { "Prefix", "" }, + { "Documentation", "doc" }, + { "Headers", "include" }, + { "Libraries", "lib" }, + { "Binaries", "bin" }, + { "Plugins", "plugins" }, + { "Imports", "imports" }, + { "Data", "" }, + { "Translations", "translations" }, + { "Examples", "" }, + { "Tests", "tests" }, +#ifdef QT_BUILD_QMAKE + { "Sysroot", "" }, + { "HostPrefix", "" }, + { "HostBinaries", "bin" }, + { "HostData", "" }, +#endif +}; + /*! Returns the location specified by \a loc. */ - QString QLibraryInfo::location(LibraryLocation loc) { +#ifdef QT_BUILD_QMAKE + QString ret = rawLocation(loc); + + // Automatically prepend the sysroot to target paths + if (loc < SysrootPath || loc > LastHostPath) { + QString sysroot = rawLocation(SysrootPath); + if (!sysroot.isEmpty() && ret.length() > 2 && ret.at(1) == QLatin1Char(':') + && (ret.at(2) == QLatin1Char('/') || ret.at(2) == QLatin1Char('\\'))) + ret.replace(0, 2, sysroot); // Strip out the drive on Windows targets + else + ret.prepend(sysroot); + } + + return ret; +} + +QString +QLibraryInfo::rawLocation(LibraryLocation loc) +{ +#else +# define rawLocation location +#endif QString ret; if(!QLibraryInfoPrivate::configuration()) { const char *path = 0; - switch (loc) { -#ifdef QT_CONFIGURE_PREFIX_PATH - case PrefixPath: - path = QT_CONFIGURE_PREFIX_PATH; - break; -#endif -#ifdef QT_CONFIGURE_DOCUMENTATION_PATH - case DocumentationPath: - path = QT_CONFIGURE_DOCUMENTATION_PATH; - break; -#endif -#ifdef QT_CONFIGURE_HEADERS_PATH - case HeadersPath: - path = QT_CONFIGURE_HEADERS_PATH; - break; -#endif -#ifdef QT_CONFIGURE_LIBRARIES_PATH - case LibrariesPath: - path = QT_CONFIGURE_LIBRARIES_PATH; - break; -#endif -#ifdef QT_CONFIGURE_BINARIES_PATH - case BinariesPath: - path = QT_CONFIGURE_BINARIES_PATH; - break; -#endif -#ifdef QT_CONFIGURE_PLUGINS_PATH - case PluginsPath: - path = QT_CONFIGURE_PLUGINS_PATH; - break; -#endif -#ifdef QT_CONFIGURE_IMPORTS_PATH - case ImportsPath: - path = QT_CONFIGURE_IMPORTS_PATH; - break; -#endif -#ifdef QT_CONFIGURE_DATA_PATH - case DataPath: - path = QT_CONFIGURE_DATA_PATH; - break; -#endif -#ifdef QT_CONFIGURE_TRANSLATIONS_PATH - case TranslationsPath: - path = QT_CONFIGURE_TRANSLATIONS_PATH; - break; -#endif -#ifdef QT_CONFIGURE_SETTINGS_PATH - case SettingsPath: + if (loc >= 0 && loc < sizeof(qt_configure_prefix_path_strs)/sizeof(qt_configure_prefix_path_strs[0])) + path = qt_configure_prefix_path_strs[loc] + 12; +#ifndef Q_OS_WIN // On Windows we use the registry + else if (loc == SettingsPath) path = QT_CONFIGURE_SETTINGS_PATH; - break; #endif -#ifdef QT_CONFIGURE_EXAMPLES_PATH - case ExamplesPath: - path = QT_CONFIGURE_EXAMPLES_PATH; - break; -#endif -#ifdef QT_CONFIGURE_TESTS_PATH - case TestsPath: - path = QT_CONFIGURE_TESTS_PATH; - break; -#endif - default: - break; - } if (path) ret = QString::fromLocal8Bit(path); } else { QString key; QString defaultValue; - switch(loc) { - case PrefixPath: - key = QLatin1String("Prefix"); - break; - case DocumentationPath: - key = QLatin1String("Documentation"); - defaultValue = QLatin1String("doc"); - break; - case HeadersPath: - key = QLatin1String("Headers"); - defaultValue = QLatin1String("include"); - break; - case LibrariesPath: - key = QLatin1String("Libraries"); - defaultValue = QLatin1String("lib"); - break; - case BinariesPath: - key = QLatin1String("Binaries"); - defaultValue = QLatin1String("bin"); - break; - case PluginsPath: - key = QLatin1String("Plugins"); - defaultValue = QLatin1String("plugins"); - break; - case ImportsPath: - key = QLatin1String("Imports"); - defaultValue = QLatin1String("imports"); - break; - case DataPath: - key = QLatin1String("Data"); - break; - case TranslationsPath: - key = QLatin1String("Translations"); - defaultValue = QLatin1String("translations"); - break; - case SettingsPath: - key = QLatin1String("Settings"); - break; - case ExamplesPath: - key = QLatin1String("Examples"); - break; - case TestsPath: - key = QLatin1String("Tests"); - defaultValue = QLatin1String("tests"); - break; - default: - break; + if (loc >= 0 && loc < sizeof(qtConfEntries)/sizeof(qtConfEntries[0])) { + key = QLatin1String(qtConfEntries[loc].key); + defaultValue = QLatin1String(qtConfEntries[loc].value); } +#ifndef Q_OS_WIN // On Windows we use the registry + else if (loc == SettingsPath) + key = QLatin1String("Settings"); +#endif if(!key.isNull()) { QSettings *config = QLibraryInfoPrivate::configuration(); @@ -366,11 +311,19 @@ QLibraryInfo::location(LibraryLocation loc) if (QDir::isRelativePath(ret)) { QString baseDir; - if (loc == PrefixPath) { - // we make the prefix path absolute to the executable's directory -#ifdef BOOTSTRAPPING +#ifdef QT_BUILD_QMAKE + if (loc == HostPrefixPath || loc == PrefixPath) { + // We make the prefix path absolute to the executable's directory. + // loc == PrefixPath while a sysroot is set would make no sense here. baseDir = QFileInfo(qmake_libraryInfoFile()).absolutePath(); + } else if (loc == SysrootPath) { + // The sysroot is bare + return ret; + } else if (loc > SysrootPath && loc <= LastHostPath) { + // We make any other host path absolute to the host prefix directory. + baseDir = rawLocation(HostPrefixPath); #else + if (loc == PrefixPath) { if (QCoreApplication::instance()) { #ifdef Q_OS_MAC CFBundleRef bundleRef = CFBundleGetMainBundle(); @@ -382,6 +335,7 @@ QLibraryInfo::location(LibraryLocation loc) } } #endif + // We make the prefix path absolute to the executable's directory. baseDir = QCoreApplication::applicationDirPath(); } else { baseDir = QDir::currentPath(); @@ -389,7 +343,7 @@ QLibraryInfo::location(LibraryLocation loc) #endif } else { // we make any other path absolute to the prefix directory - baseDir = location(PrefixPath); + baseDir = rawLocation(PrefixPath); } ret = QDir::cleanPath(baseDir + QLatin1Char('/') + ret); } @@ -413,9 +367,9 @@ QLibraryInfo::location(LibraryLocation loc) \value ImportsPath The location of installed QML extensions to import. \value DataPath The location of general Qt data. \value TranslationsPath The location of translation information for Qt strings. - \value SettingsPath The location for Qt settings. \value ExamplesPath The location for examples upon install. \value TestsPath The location of installed Qt testcases. + \value SettingsPath The location for Qt settings. Not applicable on Windows. \sa location() */ @@ -443,9 +397,9 @@ void qt_core_boilerplate() "Library path: %s\n" "Include path: %s\n", qt_configure_installation + 12, - qt_configure_prefix_path_str + 12, - qt_configure_libraries_path_str + 12, - qt_configure_headers_path_str + 12); + qt_configure_prefix_path_strs[QT_PREPEND_NAMESPACE(QLibraryInfo)::PrefixPath] + 12, + qt_configure_prefix_path_strs[QT_PREPEND_NAMESPACE(QLibraryInfo)::LibrariesPath] + 12, + qt_configure_prefix_path_strs[QT_PREPEND_NAMESPACE(QLibraryInfo)::HeadersPath] + 12); QT_PREPEND_NAMESPACE(qDumpCPUFeatures)(); diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h index 66f3d40792..d180e63198 100644 --- a/src/corelib/global/qlibraryinfo.h +++ b/src/corelib/global/qlibraryinfo.h @@ -66,20 +66,32 @@ public: enum LibraryLocation { - PrefixPath, + PrefixPath = 0, DocumentationPath, HeadersPath, LibrariesPath, BinariesPath, PluginsPath, + ImportsPath, DataPath, TranslationsPath, - SettingsPath, ExamplesPath, - ImportsPath, - TestsPath + TestsPath, + // Insert new values above this line +#ifdef QT_BUILD_QMAKE + // These are not subject to binary compatibility constraints + SysrootPath, + HostPrefixPath, + HostBinariesPath, + HostDataPath, + LastHostPath = HostDataPath, +#endif + SettingsPath = 100 }; static QString location(LibraryLocation); // ### Qt 5: consider renaming it to path() +#ifdef QT_BUILD_QMAKE + static QString rawLocation(LibraryLocation); +#endif private: QLibraryInfo(); diff --git a/src/corelib/global/qtypeinfo.h b/src/corelib/global/qtypeinfo.h index 6297b35b9c..1c08bbe1cf 100644 --- a/src/corelib/global/qtypeinfo.h +++ b/src/corelib/global/qtypeinfo.h @@ -49,15 +49,12 @@ QT_BEGIN_NAMESPACE /* QTypeInfo - type trait functionality - qIsDetached - data sharing functionality */ /* The catch-all template. */ -template <typename T> inline bool qIsDetached(T &) { return true; } - template <typename T> class QTypeInfo { @@ -161,6 +158,10 @@ public: \ template<> \ Q_DECLARE_TYPEINFO_BODY(TYPE, FLAGS) +/* Specialize QTypeInfo for QFlags<T> */ +template<typename T> class QFlags; +template<typename T> +Q_DECLARE_TYPEINFO_BODY(QFlags<T>, Q_PRIMITIVE_TYPE); /* Specialize a shared type with: @@ -184,7 +185,6 @@ QT_BEGIN_NAMESPACE #endif #define Q_DECLARE_SHARED(TYPE) \ -template <> inline bool qIsDetached<TYPE>(TYPE &t) { return t.isDetached(); } \ template <> inline void qSwap<TYPE>(TYPE &value1, TYPE &value2) \ { qSwap(value1.data_ptr(), value2.data_ptr()); } \ Q_DECLARE_SHARED_STL(TYPE) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 5e466e480d..e8ff6107ce 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -476,12 +476,12 @@ bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool crea slash = dirName.length(); } if (slash) { - QByteArray chunk = QFile::encodeName(dirName.left(slash)); + const QByteArray chunk = QFile::encodeName(dirName.left(slash)); QT_STATBUF st; - if (QT_STAT(chunk, &st) != -1) { + if (QT_STAT(chunk.constData(), &st) != -1) { if ((st.st_mode & S_IFMT) != S_IFDIR) return false; - } else if (QT_MKDIR(chunk, 0777) != 0) { + } else if (QT_MKDIR(chunk.constData(), 0777) != 0) { return false; } } @@ -492,7 +492,7 @@ bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool crea if (dirName.endsWith(QLatin1Char('/'))) dirName.chop(1); #endif - return (QT_MKDIR(QFile::encodeName(dirName), 0777) == 0); + return (QT_MKDIR(QFile::encodeName(dirName).constData(), 0777) == 0); } //static @@ -501,12 +501,12 @@ bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool remo if (removeEmptyParents) { QString dirName = QDir::cleanPath(entry.filePath()); for (int oldslash = 0, slash=dirName.length(); slash > 0; oldslash = slash) { - QByteArray chunk = QFile::encodeName(dirName.left(slash)); + const QByteArray chunk = QFile::encodeName(dirName.left(slash)); QT_STATBUF st; - if (QT_STAT(chunk, &st) != -1) { + if (QT_STAT(chunk.constData(), &st) != -1) { if ((st.st_mode & S_IFMT) != S_IFDIR) return false; - if (::rmdir(chunk) != 0) + if (::rmdir(chunk.constData()) != 0) return oldslash != 0; } else { return false; @@ -515,7 +515,7 @@ bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool remo } return true; } - return rmdir(QFile::encodeName(entry.filePath())) == 0; + return rmdir(QFile::encodeName(entry.filePath()).constData()) == 0; } //static @@ -623,7 +623,7 @@ QString QFileSystemEngine::tempPath() bool QFileSystemEngine::setCurrentPath(const QFileSystemEntry &path) { int r; - r = QT_CHDIR(path.nativeFilePath()); + r = QT_CHDIR(path.nativeFilePath().constData()); return r >= 0; } diff --git a/src/corelib/io/qfilesystemwatcher_polling_p.h b/src/corelib/io/qfilesystemwatcher_polling_p.h index 14f6345412..e50082c6d3 100644 --- a/src/corelib/io/qfilesystemwatcher_polling_p.h +++ b/src/corelib/io/qfilesystemwatcher_polling_p.h @@ -58,6 +58,7 @@ #include <QtCore/qdatetime.h> #include <QtCore/qdir.h> #include <QtCore/qtimer.h> +#include <QtCore/qhash.h> #include "qfilesystemwatcher_p.h" diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index e4d90e000a..1ec0390235 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -1752,10 +1752,10 @@ bool QConfFileSettingsPrivate::readIniFile(const QByteArray &data, iniSection = iniSection.trimmed(); - if (qstricmp(iniSection, "general") == 0) { + if (qstricmp(iniSection.constData(), "general") == 0) { currentSection.clear(); } else { - if (qstricmp(iniSection, "%general") == 0) { + if (qstricmp(iniSection.constData(), "%general") == 0) { currentSection = QLatin1String(iniSection.constData() + 1); } else { currentSection.clear(); @@ -1912,7 +1912,7 @@ bool QConfFileSettingsPrivate::writeIniFile(QIODevice &device, const ParsedSetti if (realSection.isEmpty()) { realSection = "[General]"; - } else if (qstricmp(realSection, "general") == 0) { + } else if (qstricmp(realSection.constData(), "general") == 0) { realSection = "[%General]"; } else { realSection.prepend('['); diff --git a/src/corelib/io/qstandardpaths_unix.cpp b/src/corelib/io/qstandardpaths_unix.cpp index 62c846738e..5499751751 100644 --- a/src/corelib/io/qstandardpaths_unix.cpp +++ b/src/corelib/io/qstandardpaths_unix.cpp @@ -42,6 +42,7 @@ #include "qstandardpaths.h" #include <qdir.h> #include <qfile.h> +#include <qhash.h> #include <qtextstream.h> #include <qcoreapplication.h> #include <private/qfilesystemengine_p.h> diff --git a/src/corelib/json/qjsonarray.cpp b/src/corelib/json/qjsonarray.cpp index cdf9192b27..433a68105d 100644 --- a/src/corelib/json/qjsonarray.cpp +++ b/src/corelib/json/qjsonarray.cpp @@ -44,6 +44,7 @@ #include <qjsonarray.h> #include <qjsonvalue.h> #include <qstringlist.h> +#include <qvariant.h> #include <qdebug.h> #include "qjsonwriter_p.h" diff --git a/src/corelib/json/qjsondocument.cpp b/src/corelib/json/qjsondocument.cpp index 8a7fa760ae..c2204bf696 100644 --- a/src/corelib/json/qjsondocument.cpp +++ b/src/corelib/json/qjsondocument.cpp @@ -44,6 +44,7 @@ #include <qjsonvalue.h> #include <qjsonarray.h> #include <qstringlist.h> +#include <qvariant.h> #include <qdebug.h> #include "qjsonwriter_p.h" #include "qjsonparser_p.h" diff --git a/src/corelib/json/qjsonobject.cpp b/src/corelib/json/qjsonobject.cpp index a854f73c7e..cfe71e8959 100644 --- a/src/corelib/json/qjsonobject.cpp +++ b/src/corelib/json/qjsonobject.cpp @@ -44,6 +44,7 @@ #include <qjsonarray.h> #include <qstringlist.h> #include <qdebug.h> +#include <qvariant.h> #include "qjson_p.h" #include "qjsonwriter_p.h" diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h index 1f36f9c9c8..cac89f2b13 100644 --- a/src/corelib/kernel/qcoreevent.h +++ b/src/corelib/kernel/qcoreevent.h @@ -288,7 +288,7 @@ public: MaxUser = 65535 // last user event id }; - QEvent(Type type); + explicit QEvent(Type type); virtual ~QEvent(); inline Type type() const { return static_cast<Type>(t); } inline bool spontaneous() const { return spont; } @@ -330,7 +330,7 @@ private: class Q_CORE_EXPORT QTimerEvent : public QEvent { public: - QTimerEvent( int timerId ); + explicit QTimerEvent( int timerId ); ~QTimerEvent(); int timerId() const { return id; } protected: @@ -355,7 +355,7 @@ protected: class Q_CORE_EXPORT QDynamicPropertyChangeEvent : public QEvent { public: - QDynamicPropertyChangeEvent(const QByteArray &name); + explicit QDynamicPropertyChangeEvent(const QByteArray &name); ~QDynamicPropertyChangeEvent(); inline QByteArray propertyName() const { return n; } diff --git a/src/corelib/kernel/qeventdispatcher_win_p.h b/src/corelib/kernel/qeventdispatcher_win_p.h index c404967e6a..565f1ef4b3 100644 --- a/src/corelib/kernel/qeventdispatcher_win_p.h +++ b/src/corelib/kernel/qeventdispatcher_win_p.h @@ -55,6 +55,7 @@ #include "QtCore/qabstracteventdispatcher.h" #include "QtCore/qt_windows.h" +#include "QtCore/qhash.h" #include "qabstracteventdispatcher_p.h" @@ -130,7 +131,7 @@ struct WinTimerInfo { // internal timer info class QZeroTimerEvent : public QTimerEvent { public: - inline QZeroTimerEvent(int timerId) + explicit inline QZeroTimerEvent(int timerId) : QTimerEvent(timerId) { t = QEvent::ZeroTimerEvent; } }; diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index beb7294abd..f969875455 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -565,6 +565,7 @@ template <class T> class QSet; template <class T> class QSharedPointer; template <class T1, class T2> class QMap; template <class T1, class T2> class QHash; +template <class T1, class T2> struct QPair; typedef QList<QVariant> QVariantList; typedef QMap<QString, QVariant> QVariantMap; typedef QHash<QString, QVariant> QVariantHash; @@ -586,6 +587,23 @@ struct QMetaTypeId< SINGLE_ARG_TEMPLATE<T> > \ } \ }; +#define Q_DECLARE_METATYPE_TEMPLATE_2ARG(DOUBLE_ARG_TEMPLATE) \ +template<typename T, typename U> \ +struct QMetaTypeId< DOUBLE_ARG_TEMPLATE<T, U> > \ +{ \ + enum { \ + Defined = QMetaTypeId2<T>::Defined && QMetaTypeId2<U>::Defined \ + }; \ + static int qt_metatype_id() \ + { \ + static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0); \ + if (!metatype_id.load()) \ + metatype_id.storeRelease(qRegisterMetaType< DOUBLE_ARG_TEMPLATE<T, U> >( QByteArray(QByteArray(#DOUBLE_ARG_TEMPLATE "<") + QMetaType::typeName(qMetaTypeId<T>()) + ", " + QMetaType::typeName(qMetaTypeId<U>()) + ">").constData(), \ + reinterpret_cast< DOUBLE_ARG_TEMPLATE<T, U> *>(quintptr(-1)))); \ + return metatype_id.loadAcquire(); \ + } \ +}; + Q_DECLARE_METATYPE_TEMPLATE_1ARG(QList) Q_DECLARE_METATYPE_TEMPLATE_1ARG(QVector) Q_DECLARE_METATYPE_TEMPLATE_1ARG(QQueue) @@ -594,6 +612,10 @@ Q_DECLARE_METATYPE_TEMPLATE_1ARG(QSet) Q_DECLARE_METATYPE_TEMPLATE_1ARG(QSharedPointer) Q_DECLARE_METATYPE_TEMPLATE_1ARG(QLinkedList) +Q_DECLARE_METATYPE_TEMPLATE_2ARG(QHash) +Q_DECLARE_METATYPE_TEMPLATE_2ARG(QMap) +Q_DECLARE_METATYPE_TEMPLATE_2ARG(QPair) + inline QMetaType::QMetaType(const ExtensionFlag extensionFlags, const QMetaTypeInterface *info, Creator creator, Deleter deleter, diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 530ddb3f13..19440e9368 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -69,6 +69,16 @@ QT_BEGIN_NAMESPACE +struct QObjectPrivate::ExtraData +{ + ExtraData() {} +#ifndef QT_NO_USERDATA + QVector<QObjectUserData *> userData; +#endif + QList<QByteArray> propertyNames; + QList<QVariant> propertyValues; +}; + static int DIRECT_CONNECTION_ONLY = 0; static int *queuedConnectionTypes(const QList<QByteArray> &typeNames) diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 710aa630d9..c8edadce9d 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -60,7 +60,6 @@ #include "QtCore/qlist.h" #include "QtCore/qvector.h" #include "QtCore/qreadwritelock.h" -#include "QtCore/qvariant.h" QT_BEGIN_NAMESPACE @@ -98,16 +97,8 @@ class Q_CORE_EXPORT QObjectPrivate : public QObjectData { Q_DECLARE_PUBLIC(QObject) + struct ExtraData; public: - struct ExtraData - { - ExtraData() {} -#ifndef QT_NO_USERDATA - QVector<QObjectUserData *> userData; -#endif - QList<QByteArray> propertyNames; - QList<QVariant> propertyValues; - }; typedef void (*StaticMetaCallFunction)(QObject *, QMetaObject::Call, int, void **); struct Connection diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index 15daf223b9..4b3829b53e 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -210,16 +210,16 @@ Q_CORE_EXPORT const char *qFlagLocation(const char *method); #ifndef QT_NO_DEBUG # define QLOCATION "\0" __FILE__ ":" QTOSTRING(__LINE__) # ifndef QT_NO_KEYWORDS -# define METHOD(a) qFlagLocation("0"#a QLOCATION) +# define METHOD(a) qFlagLocation("0" QTOSTRING(a) QLOCATION) # endif -# define SLOT(a) qFlagLocation("1"#a QLOCATION) -# define SIGNAL(a) qFlagLocation("2"#a QLOCATION) +# define SLOT(a) qFlagLocation("1" QTOSTRING(a) QLOCATION) +# define SIGNAL(a) qFlagLocation("2" QTOSTRING(a) QLOCATION) #else # ifndef QT_NO_KEYWORDS -# define METHOD(a) "0"#a +# define METHOD(a) "0" QTOSTRING(a) # endif -# define SLOT(a) "1"#a -# define SIGNAL(a) "2"#a +# define SLOT(a) "1" QTOSTRING(a) +# define SIGNAL(a) "2" QTOSTRING(a) #endif #define QMETHOD_CODE 0 // member type codes diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 4f3e4f8b4e..029a261faf 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -1696,7 +1696,7 @@ void QVariant::load(QDataStream &s) if (typeId == QVariant::UserType) { QByteArray name; s >> name; - typeId = QMetaType::type(name); + typeId = QMetaType::type(name.constData()); if (!typeId) { s.setStatus(QDataStream::ReadCorruptData); return; diff --git a/src/corelib/thread/qbasicatomic.h b/src/corelib/thread/qbasicatomic.h index 96338c62dc..01a69dbd8b 100644 --- a/src/corelib/thread/qbasicatomic.h +++ b/src/corelib/thread/qbasicatomic.h @@ -136,7 +136,7 @@ public: // Atomic API, implemented in qatomic_XXX.h - T loadAcquire() { return Ops::loadAcquire(_q_value); } + T loadAcquire() const { return Ops::loadAcquire(_q_value); } void storeRelease(T newValue) { Ops::storeRelease(_q_value, newValue); } static bool isReferenceCountingNative() { return Ops::isReferenceCountingNative(); } @@ -206,7 +206,7 @@ public: void store(Type newValue) { _q_value = newValue; } // Atomic API, implemented in qatomic_XXX.h - Type loadAcquire() { return Ops::loadAcquire(_q_value); } + Type loadAcquire() const { return Ops::loadAcquire(_q_value); } void storeRelease(Type newValue) { Ops::storeRelease(_q_value, newValue); } static bool isTestAndSetNative() { return Ops::isTestAndSetNative(); } diff --git a/src/corelib/thread/qgenericatomic.h b/src/corelib/thread/qgenericatomic.h index f4d5e2f8d9..34c040c39b 100644 --- a/src/corelib/thread/qgenericatomic.h +++ b/src/corelib/thread/qgenericatomic.h @@ -85,7 +85,7 @@ template <typename BaseClass> struct QGenericAtomicOps static void orderedMemoryFence() { } template <typename T> static inline always_inline - T load(T &_q_value) + T load(const T &_q_value) { return _q_value; } @@ -97,9 +97,9 @@ template <typename BaseClass> struct QGenericAtomicOps } template <typename T> static inline always_inline - T loadAcquire(T &_q_value) + T loadAcquire(const T &_q_value) { - T tmp = *static_cast<volatile T *>(&_q_value); + T tmp = *static_cast<const volatile T *>(&_q_value); BaseClass::acquireMemoryFence(); return tmp; } diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index 445fe5cd81..b6719c9536 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -343,7 +343,7 @@ int qstrcmp(const QByteArray &str1, const QByteArray &str2) { int l1 = str1.length(); int l2 = str2.length(); - int ret = memcmp(str1, str2, qMin(l1, l2)); + int ret = memcmp(str1.constData(), str2.constData(), qMin(l1, l2)); if (ret != 0) return ret; @@ -995,6 +995,8 @@ QByteArray &QByteArray::operator=(const char *str) /*! \fn QByteArray::operator const char *() const \fn QByteArray::operator const void *() const + \obsolete Use constData() instead. + Returns a pointer to the data stored in the byte array. The pointer can be used to access the bytes that compose the array. The data is '\\0'-terminated. The pointer remains valid as long @@ -2751,7 +2753,7 @@ QDataStream &operator<<(QDataStream &out, const QByteArray &ba) out << (quint32)0xffffffff; return out; } - return out.writeBytes(ba, ba.size()); + return out.writeBytes(ba.constData(), ba.size()); } /*! \relates QByteArray diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h index 8202097da5..09c43988fd 100644 --- a/src/corelib/tools/qbytearray.h +++ b/src/corelib/tools/qbytearray.h @@ -207,8 +207,10 @@ public: void squeeze(); #ifndef QT_NO_CAST_FROM_BYTEARRAY - operator const char *() const; - operator const void *() const; +#if QT_DEPRECATED_SINCE(5, 0) + QT_DEPRECATED operator const char *() const { return constData(); } + QT_DEPRECATED operator const void *() const { return constData(); } +#endif #endif char *data(); const char *data() const; @@ -415,12 +417,6 @@ inline char QByteArray::operator[](uint i) const inline bool QByteArray::isEmpty() const { return d->size == 0; } -#ifndef QT_NO_CAST_FROM_BYTEARRAY -inline QByteArray::operator const char *() const -{ return d->data(); } -inline QByteArray::operator const void *() const -{ return d->data(); } -#endif inline char *QByteArray::data() { detach(); return d->data(); } inline const char *QByteArray::data() const diff --git a/src/corelib/tools/qcryptographichash.h b/src/corelib/tools/qcryptographichash.h index 2bfc03373a..6ebe389faf 100644 --- a/src/corelib/tools/qcryptographichash.h +++ b/src/corelib/tools/qcryptographichash.h @@ -65,7 +65,7 @@ public: Sha512 }; - QCryptographicHash(Algorithm method); + explicit QCryptographicHash(Algorithm method); ~QCryptographicHash(); void reset(); diff --git a/src/corelib/tools/qlocale.h b/src/corelib/tools/qlocale.h index c029f627b2..2ecd934100 100644 --- a/src/corelib/tools/qlocale.h +++ b/src/corelib/tools/qlocale.h @@ -42,7 +42,6 @@ #ifndef QLOCALE_H #define QLOCALE_H -#include <QtCore/qvariant.h> #include <QtCore/qstring.h> #include <QtCore/qobjectdefs.h> diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h index c6902ca206..ad7c9706c4 100644 --- a/src/corelib/tools/qlocale_p.h +++ b/src/corelib/tools/qlocale_p.h @@ -55,7 +55,7 @@ #include "QtCore/qstring.h" #include "QtCore/qvarlengtharray.h" -#include "QtCore/qmetatype.h" +#include "QtCore/qvariant.h" #include "qlocale.h" diff --git a/src/corelib/tools/qlocale_unix.cpp b/src/corelib/tools/qlocale_unix.cpp index 6ace96f771..f2876912b4 100644 --- a/src/corelib/tools/qlocale_unix.cpp +++ b/src/corelib/tools/qlocale_unix.cpp @@ -98,7 +98,7 @@ QLocale QSystemLocale::fallbackLocale() const lang = qgetenv("LC_NUMERIC"); if (lang.isEmpty()) lang = qgetenv("LANG"); - return QLocale(QLatin1String(lang)); + return QLocale(QString::fromLatin1(lang)); } QVariant QSystemLocale::query(QueryType type, QVariant in) const diff --git a/src/corelib/tools/qpair.h b/src/corelib/tools/qpair.h index 5df33a4e9d..4dc28f2d26 100644 --- a/src/corelib/tools/qpair.h +++ b/src/corelib/tools/qpair.h @@ -63,6 +63,22 @@ struct QPair T2 second; }; +// mark QPair<T1,T2> as complex/movable/primitive depending on the +// typeinfos of the constituents: +template<class T1, class T2> +class QTypeInfo< QPair<T1, T2> > +{ +public: + enum { + isComplex = QTypeInfo<T1>::isComplex || QTypeInfo<T2>::isComplex, + isStatic = QTypeInfo<T1>::isStatic || QTypeInfo<T2>::isStatic, + isLarge = sizeof(QPair<T1, T2>) > sizeof(void*), + isPointer = false, + isDummy = false, + sizeOf = sizeof(QPair<T1, T2>) + }; +}; + template <class T1, class T2> Q_INLINE_TEMPLATE bool operator==(const QPair<T1, T2> &p1, const QPair<T1, T2> &p2) { return p1.first == p2.first && p1.second == p2.second; } diff --git a/src/corelib/tools/qscopedvaluerollback.h b/src/corelib/tools/qscopedvaluerollback.h index 23d2d9eda0..d53cabd315 100644 --- a/src/corelib/tools/qscopedvaluerollback.h +++ b/src/corelib/tools/qscopedvaluerollback.h @@ -51,7 +51,7 @@ template <typename T> class QScopedValueRollback { public: - QScopedValueRollback(T &var) : + explicit QScopedValueRollback(T &var) : varRef(var) { oldValue = varRef; diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 45ccfb8aea..083abcbaad 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -2132,7 +2132,8 @@ QString &QString::replace(QChar c, const QLatin1String &after, Qt::CaseSensitivi /*! - Returns true if string \a other is equal to this string; otherwise + \relates QString + Returns true if string \a s1 is equal to string \a s2; otherwise returns false. The comparison is based exclusively on the numeric Unicode values of @@ -2140,12 +2141,12 @@ QString &QString::replace(QChar c, const QLatin1String &after, Qt::CaseSensitivi expect. Consider sorting user-interface strings with localeAwareCompare(). */ -bool QString::operator==(const QString &other) const +bool operator==(const QString &s1, const QString &s2) { - if (d->size != other.d->size) + if (s1.d->size != s2.d->size) return false; - return qMemEquals(d->data(), other.d->data(), d->size); + return qMemEquals(s1.d->data(), s2.d->data(), s1.d->size); } /*! @@ -2200,17 +2201,18 @@ bool QString::operator==(const QLatin1String &other) const */ /*! - Returns true if this string is lexically less than string \a - other; otherwise returns false. + \relates QString + Returns true if string \a s1 is lexically less than string + \a s2; otherwise returns false. The comparison is based exclusively on the numeric Unicode values of the characters and is very fast, but is not what a human would expect. Consider sorting user-interface strings using the QString::localeAwareCompare() function. */ -bool QString::operator<(const QString &other) const +bool operator<(const QString &s1, const QString &s2) { - return ucstrcmp(constData(), length(), other.constData(), other.length()) < 0; + return ucstrcmp(s1.constData(), s1.length(), s2.constData(), s2.length()) < 0; } /*! @@ -2261,10 +2263,11 @@ bool QString::operator<(const QLatin1String &other) const go through QObject::tr(), for example. */ -/*! \fn bool QString::operator<=(const QString &other) const +/*! \fn bool operator<=(const QString &s1, const QString &s2) + \relates QString - Returns true if this string is lexically less than or equal to - string \a other; otherwise returns false. + Returns true if string \a s1 is lexically less than or equal to + string \a s2; otherwise returns false. The comparison is based exclusively on the numeric Unicode values of the characters and is very fast, but is not what a human would @@ -2304,10 +2307,11 @@ bool QString::operator<(const QLatin1String &other) const go through QObject::tr(), for example. */ -/*! \fn bool QString::operator>(const QString &other) const +/*! \fn bool operator>(const QString &s1, const QString &s2) + \relates QString - Returns true if this string is lexically greater than string \a - other; otherwise returns false. + Returns true if string \a s1 is lexically greater than string \a + s2; otherwise returns false. The comparison is based exclusively on the numeric Unicode values of the characters and is very fast, but is not what a human would @@ -2363,10 +2367,11 @@ bool QString::operator>(const QLatin1String &other) const for example. */ -/*! \fn bool QString::operator>=(const QString &other) const +/*! \fn bool operator>=(const QString &s1, const QString &s2) + \relates QString - Returns true if this string is lexically greater than or equal to - string \a other; otherwise returns false. + Returns true if string \a s1 is lexically greater than or equal to + string \a s2; otherwise returns false. The comparison is based exclusively on the numeric Unicode values of the characters and is very fast, but is not what a human would @@ -2406,9 +2411,10 @@ bool QString::operator>(const QLatin1String &other) const for example. */ -/*! \fn bool QString::operator!=(const QString &other) const +/*! \fn bool operator!=(const QString &s1, const QString &s2) + \relates QString - Returns true if this string is not equal to string \a other; + Returns true if string \a s1 is not equal to string \a s2; otherwise returns false. The comparison is based exclusively on the numeric Unicode values @@ -4727,7 +4733,7 @@ int QString::localeAwareCompare_helper(const QChar *data1, int length1, } // else fall through # endif // declared in <string.h> - int delta = strcoll(toLocal8Bit_helper(data1, length1), toLocal8Bit_helper(data2, length2)); + int delta = strcoll(toLocal8Bit_helper(data1, length1).constData(), toLocal8Bit_helper(data2, length2).constData()); if (delta == 0) delta = ucstrcmp(data1, length1, data2, length2); return delta; diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index b1ade85a30..6fc86fc04b 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -417,6 +417,10 @@ public: { return fromLocal8Bit_helper(str, (str && size == -1) ? int(strlen(str)) : size); } + static inline QString fromAscii(const QByteArray &str) { return fromAscii(str.data(), str.size()); } + static inline QString fromLatin1(const QByteArray &str) { return fromLatin1(str.data(), str.size()); } + static inline QString fromUtf8(const QByteArray &str) { return fromUtf8(str.data(), str.size()); } + static inline QString fromLocal8Bit(const QByteArray &str) { return fromLocal8Bit(str.data(), str.size()); } static QString fromUtf16(const ushort *, int size = -1); static QString fromUcs4(const uint *, int size = -1); static QString fromRawData(const QChar *, int size); @@ -482,12 +486,12 @@ public: static QString number(qulonglong, int base=10); static QString number(double, char f='g', int prec=6); - bool operator==(const QString &s) const; - bool operator<(const QString &s) const; - inline bool operator>(const QString &s) const { return s < *this; } - inline bool operator!=(const QString &s) const { return !operator==(s); } - inline bool operator<=(const QString &s) const { return !operator>(s); } - inline bool operator>=(const QString &s) const { return !operator<(s); } + friend Q_CORE_EXPORT bool operator==(const QString &s1, const QString &s2); + friend Q_CORE_EXPORT bool operator<(const QString &s1, const QString &s2); + friend inline bool operator>(const QString &s1, const QString &s2) { return s2 < s1; } + friend inline bool operator!=(const QString &s1, const QString &s2) { return !(s1 == s2); } + friend inline bool operator<=(const QString &s1, const QString &s2) { return !(s1 > s2); } + friend inline bool operator>=(const QString &s1, const QString &s2) { return !(s1 < s2); } bool operator==(const QLatin1String &s) const; bool operator<(const QLatin1String &s) const; diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h index 4c963185ad..e34425be7e 100644 --- a/src/corelib/tools/qstringbuilder.h +++ b/src/corelib/tools/qstringbuilder.h @@ -45,12 +45,6 @@ #include <QtCore/qstring.h> #include <QtCore/qbytearray.h> -#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) -# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ == 0) -# include <QtCore/qmap.h> -# endif -#endif - #include <string.h> QT_BEGIN_HEADER @@ -173,6 +167,16 @@ template <> struct QConcatenable<QChar> : private QAbstractConcatenable { *out++ = c; } }; +template <> struct QConcatenable<QChar::SpecialCharacter> : private QAbstractConcatenable +{ + typedef QChar::SpecialCharacter type; + typedef QString ConvertTo; + enum { ExactSize = true }; + static int size(const QChar::SpecialCharacter) { return 1; } + static inline void appendTo(const QChar::SpecialCharacter c, QChar *&out) + { *out++ = c; } +}; + template <> struct QConcatenable<QCharRef> : private QAbstractConcatenable { typedef QCharRef type; diff --git a/src/corelib/tools/qstringmatcher.h b/src/corelib/tools/qstringmatcher.h index a9b2a7c371..3f614f732c 100644 --- a/src/corelib/tools/qstringmatcher.h +++ b/src/corelib/tools/qstringmatcher.h @@ -55,7 +55,7 @@ class Q_CORE_EXPORT QStringMatcher { public: QStringMatcher(); - QStringMatcher(const QString &pattern, + explicit QStringMatcher(const QString &pattern, Qt::CaseSensitivity cs = Qt::CaseSensitive); QStringMatcher(const QChar *uc, int len, Qt::CaseSensitivity cs = Qt::CaseSensitive); diff --git a/src/corelib/xml/qxmlstream.h b/src/corelib/xml/qxmlstream.h index 3a9ddfd990..90382c7fe5 100644 --- a/src/corelib/xml/qxmlstream.h +++ b/src/corelib/xml/qxmlstream.h @@ -248,10 +248,10 @@ public: QXmlStreamReader(); - QXmlStreamReader(QIODevice *device); - QXmlStreamReader(const QByteArray &data); - QXmlStreamReader(const QString &data); - QXmlStreamReader(const char * data); + explicit QXmlStreamReader(QIODevice *device); + explicit QXmlStreamReader(const QByteArray &data); + explicit QXmlStreamReader(const QString &data); + explicit QXmlStreamReader(const char * data); ~QXmlStreamReader(); void setDevice(QIODevice *device); @@ -361,9 +361,9 @@ class Q_CORE_EXPORT QXmlStreamWriter QDOC_PROPERTY(int autoFormattingIndent READ autoFormattingIndent WRITE setAutoFormattingIndent) public: QXmlStreamWriter(); - QXmlStreamWriter(QIODevice *device); - QXmlStreamWriter(QByteArray *array); - QXmlStreamWriter(QString *string); + explicit QXmlStreamWriter(QIODevice *device); + explicit QXmlStreamWriter(QByteArray *array); + explicit QXmlStreamWriter(QString *string); ~QXmlStreamWriter(); void setDevice(QIODevice *device); diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 6ce08d93cc..3e53b04728 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -5132,7 +5132,8 @@ bool qt_xForm_helper(const QTransform &trueMat, int xoffset, int type, int depth #undef IWX_LSB #undef IWX_PIX -/*! \obsolete +/*! \fn int QImage::serialNumber() const + \obsolete Returns a number that identifies the contents of this QImage object. Distinct QImage objects can only have the same serial number if they refer to the same contents (but they don't @@ -5147,14 +5148,6 @@ bool qt_xForm_helper(const QTransform &trueMat, int xoffset, int type, int depth \sa operator==() */ -int QImage::serialNumber() const -{ - if (!d) - return 0; - else - return d->ser_no; -} - /*! Returns a number that identifies the contents of this QImage object. Distinct QImage objects can only have the same key if they diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index 5a3ae8f886..e9192f1031 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -253,7 +253,9 @@ public: inline static QImage fromData(const QByteArray &data, const char *format = 0) { return fromData(reinterpret_cast<const uchar *>(data.constData()), data.size(), format); } - int serialNumber() const; +#if QT_DEPRECATED_SINCE(5, 0) + QT_DEPRECATED inline int serialNumber() const { return cacheKey() >> 32; } +#endif qint64 cacheKey() const; QPaintEngine *paintEngine() const; diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 504f583baf..65b9d62dfa 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -885,7 +885,8 @@ void QPixmap::fill(const QColor &color) data->fill(color); } -/*! \obsolete +/*! \fn int QPixmap::serialNumber() const + \obsolete Returns a number that identifies the contents of this QPixmap object. Distinct QPixmap objects can only have the same serial number if they refer to the same contents (but they don't have @@ -898,12 +899,6 @@ void QPixmap::fill(const QColor &color) it as a cache key. For caching pixmaps, we recommend using the QPixmapCache class whenever possible. */ -int QPixmap::serialNumber() const -{ - if (isNull()) - return 0; - return data->serialNumber(); -} /*! Returns a number that identifies this QPixmap. Distinct QPixmap diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h index 27bfe15688..3d78a43917 100644 --- a/src/gui/image/qpixmap.h +++ b/src/gui/image/qpixmap.h @@ -146,7 +146,7 @@ public: void scroll(int dx, int dy, const QRect &rect, QRegion *exposed = 0); #if QT_DEPRECATED_SINCE(5, 0) - QT_DEPRECATED int serialNumber() const; + QT_DEPRECATED inline int serialNumber() const { return cacheKey() >> 32; } #endif qint64 cacheKey() const; diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp index 8125b1360d..7c7c4652e3 100644 --- a/src/gui/image/qpixmap_raster.cpp +++ b/src/gui/image/qpixmap_raster.cpp @@ -115,7 +115,7 @@ void QRasterPlatformPixmap::resize(int width, int height) image.setColor(1, QColor(Qt::color1).rgba()); } - setSerialNumber(image.serialNumber()); + setSerialNumber(image.cacheKey() >> 32); } bool QRasterPlatformPixmap::fromData(const uchar *buffer, uint len, const char *format, @@ -349,7 +349,7 @@ void QRasterPlatformPixmap::createPixmapForImage(QImage &sourceImage, Qt::ImageC } is_null = (w <= 0 || h <= 0); - setSerialNumber(image.serialNumber()); + setSerialNumber(image.cacheKey() >> 32); } QImage* QRasterPlatformPixmap::buffer() diff --git a/src/gui/image/qpixmapcache_p.h b/src/gui/image/qpixmapcache_p.h index 6ca109b03f..426a6d9954 100644 --- a/src/gui/image/qpixmapcache_p.h +++ b/src/gui/image/qpixmapcache_p.h @@ -96,8 +96,6 @@ public: QPixmapCache::Key key; }; -inline bool qIsDetached(QPixmapCacheEntry &t) { return t.isDetached(); } - QT_END_NAMESPACE #endif // QPIXMAPCACHE_P_H diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index ca93095a94..d70f6be201 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -71,7 +71,7 @@ class QScreen; class Q_GUI_EXPORT QInputEvent : public QEvent { public: - QInputEvent(Type type, Qt::KeyboardModifiers modifiers = Qt::NoModifier); + explicit QInputEvent(Type type, Qt::KeyboardModifiers modifiers = Qt::NoModifier); ~QInputEvent(); inline Qt::KeyboardModifiers modifiers() const { return modState; } inline void setModifiers(Qt::KeyboardModifiers amodifiers) { modState = amodifiers; } @@ -276,7 +276,7 @@ protected: class Q_GUI_EXPORT QFocusEvent : public QEvent { public: - QFocusEvent(Type type, Qt::FocusReason reason=Qt::OtherFocusReason); + explicit QFocusEvent(Type type, Qt::FocusReason reason=Qt::OtherFocusReason); ~QFocusEvent(); inline bool gotFocus() const { return type() == FocusIn; } @@ -292,8 +292,8 @@ private: class Q_GUI_EXPORT QPaintEvent : public QEvent { public: - QPaintEvent(const QRegion& paintRegion); - QPaintEvent(const QRect &paintRect); + explicit QPaintEvent(const QRegion& paintRegion); + explicit QPaintEvent(const QRect &paintRect); ~QPaintEvent(); inline const QRect &rect() const { return m_rect; } @@ -311,7 +311,7 @@ protected: class Q_GUI_EXPORT QUpdateLaterEvent : public QEvent { public: - QUpdateLaterEvent(const QRegion& paintRegion); + explicit QUpdateLaterEvent(const QRegion& paintRegion); ~QUpdateLaterEvent(); inline const QRegion ®ion() const { return m_region; } @@ -337,7 +337,7 @@ protected: class Q_GUI_EXPORT QExposeEvent : public QEvent { public: - QExposeEvent(const QRegion &rgn); + explicit QExposeEvent(const QRegion &rgn); ~QExposeEvent(); inline const QRegion ®ion() const { return rgn; } @@ -464,11 +464,12 @@ private: int replace_length; QString tentativeCommit; }; +Q_DECLARE_TYPEINFO(QInputMethodEvent::Attribute, Q_MOVABLE_TYPE); class Q_GUI_EXPORT QInputMethodQueryEvent : public QEvent { public: - QInputMethodQueryEvent(Qt::InputMethodQueries queries); + explicit QInputMethodQueryEvent(Qt::InputMethodQueries queries); ~QInputMethodQueryEvent(); Qt::InputMethodQueries queries() const { return m_queries; } @@ -586,7 +587,7 @@ private: class Q_GUI_EXPORT QStatusTipEvent : public QEvent { public: - QStatusTipEvent(const QString &tip); + explicit QStatusTipEvent(const QString &tip); ~QStatusTipEvent(); inline QString tip() const { return s; } @@ -599,7 +600,7 @@ private: class Q_GUI_EXPORT QWhatsThisClickedEvent : public QEvent { public: - QWhatsThisClickedEvent(const QString &href); + explicit QWhatsThisClickedEvent(const QString &href); ~QWhatsThisClickedEvent(); inline QString href() const { return s; } @@ -624,8 +625,8 @@ public: class Q_GUI_EXPORT QFileOpenEvent : public QEvent { public: - QFileOpenEvent(const QString &file); - QFileOpenEvent(const QUrl &url); + explicit QFileOpenEvent(const QString &file); + explicit QFileOpenEvent(const QUrl &url); ~QFileOpenEvent(); inline QString file() const { return f; } @@ -639,7 +640,7 @@ private: class Q_GUI_EXPORT QToolBarChangeEvent : public QEvent { public: - QToolBarChangeEvent(bool t); + explicit QToolBarChangeEvent(bool t); ~QToolBarChangeEvent(); inline bool toggle() const { return tog; } @@ -669,7 +670,7 @@ protected: class Q_GUI_EXPORT QClipboardEvent : public QEvent { public: - QClipboardEvent(QEventPrivate *data); + explicit QClipboardEvent(QEventPrivate *data); ~QClipboardEvent(); QEventPrivate *data() { return d; } @@ -679,7 +680,7 @@ public: class Q_GUI_EXPORT QWindowStateChangeEvent: public QEvent { public: - QWindowStateChangeEvent(Qt::WindowStates aOldState); + explicit QWindowStateChangeEvent(Qt::WindowStates aOldState); QWindowStateChangeEvent(Qt::WindowStates aOldState, bool isOverride); ~QWindowStateChangeEvent(); @@ -711,7 +712,7 @@ public: }; Q_DECLARE_FLAGS(InfoFlags, InfoFlag) - TouchPoint(int id = -1); + explicit TouchPoint(int id = -1); TouchPoint(const QTouchEvent::TouchPoint &other); ~TouchPoint(); @@ -783,11 +784,11 @@ public: }; #endif - QTouchEvent(QEvent::Type eventType, - QTouchDevice *device = 0, - Qt::KeyboardModifiers modifiers = Qt::NoModifier, - Qt::TouchPointStates touchPointStates = 0, - const QList<QTouchEvent::TouchPoint> &touchPoints = QList<QTouchEvent::TouchPoint>()); + explicit QTouchEvent(QEvent::Type eventType, + QTouchDevice *device = 0, + Qt::KeyboardModifiers modifiers = Qt::NoModifier, + Qt::TouchPointStates touchPointStates = 0, + const QList<QTouchEvent::TouchPoint> &touchPoints = QList<QTouchEvent::TouchPoint>()); ~QTouchEvent(); inline QWindow *window() const { return _window; } @@ -825,7 +826,7 @@ class QScrollPrepareEventPrivate; class Q_GUI_EXPORT QScrollPrepareEvent : public QEvent { public: - QScrollPrepareEvent(const QPointF &startPos); + explicit QScrollPrepareEvent(const QPointF &startPos); ~QScrollPrepareEvent(); QPointF startPos() const; diff --git a/src/gui/kernel/qopenglcontext_p.h b/src/gui/kernel/qopenglcontext_p.h index 3e2c35f088..d5c4d6c762 100644 --- a/src/gui/kernel/qopenglcontext_p.h +++ b/src/gui/kernel/qopenglcontext_p.h @@ -49,9 +49,7 @@ #include <private/qobject_p.h> #include <qmutex.h> -#ifndef QT_NO_DEBUG #include <QtCore/QHash> -#endif QT_BEGIN_HEADER diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp index 8ee62ce8d9..9a2eb12e3f 100644 --- a/src/gui/kernel/qpalette.cpp +++ b/src/gui/kernel/qpalette.cpp @@ -844,7 +844,8 @@ bool QPalette::isEqual(QPalette::ColorGroup group1, QPalette::ColorGroup group2) return true; } -/*! \obsolete +/*! \fn int QPalette::serialNumber() const + \obsolete Returns a number that identifies the contents of this QPalette object. Distinct QPalette objects can only have the same serial @@ -860,10 +861,6 @@ bool QPalette::isEqual(QPalette::ColorGroup group1, QPalette::ColorGroup group2) \sa operator==() */ -int QPalette::serialNumber() const -{ - return d->ser_no; -} /*! Returns a number that identifies the contents of this QPalette diff --git a/src/gui/kernel/qpalette.h b/src/gui/kernel/qpalette.h index cc710fa67a..ca619a89b4 100644 --- a/src/gui/kernel/qpalette.h +++ b/src/gui/kernel/qpalette.h @@ -139,7 +139,9 @@ public: inline bool operator!=(const QPalette &p) const { return !(operator==(p)); } bool isCopyOf(const QPalette &p) const; - int serialNumber() const; +#if QT_DEPRECATED_SINCE(5, 0) + QT_DEPRECATED inline int serialNumber() const { return cacheKey() >> 32; } +#endif qint64 cacheKey() const; QPalette resolve(const QPalette &) const; diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index a084a3dd8c..4bceb28ef7 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -1148,25 +1148,6 @@ QByteArray QFontEngine::convertToPostscriptFontFamilyName(const QByteArray &fami return f; } -class QRgbGreyPalette: public QVector<QRgb> -{ -public: - QRgbGreyPalette() - { - resize(256); - QRgb *it = data(); - for (int i = 0; i < size(); ++i, ++it) - *it = 0xff000000 | i | (i<<8) | (i<<16); - } -}; - -Q_GLOBAL_STATIC(QVector<QRgb>, qt_grayPalette) - -const QVector<QRgb> &QFontEngine::grayPalette() -{ - return *qt_grayPalette(); -} - QFixed QFontEngine::lastRightBearing(const QGlyphLayout &glyphs, bool round) { if (glyphs.numGlyphs >= 1) { diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index fed135ea87..44464ee788 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -279,7 +279,6 @@ public: int m_subPixelPositionCount; // Number of positions within a single pixel for this cache protected: - static const QVector<QRgb> &grayPalette(); QFixed lastRightBearing(const QGlyphLayout &glyphs, bool round = false); private: diff --git a/src/gui/text/qfontmetrics.h b/src/gui/text/qfontmetrics.h index 7ddc8975e4..e48460ffd0 100644 --- a/src/gui/text/qfontmetrics.h +++ b/src/gui/text/qfontmetrics.h @@ -61,7 +61,7 @@ class QRect; class Q_GUI_EXPORT QFontMetrics { public: - QFontMetrics(const QFont &); + explicit QFontMetrics(const QFont &); QFontMetrics(const QFont &, QPaintDevice *pd); QFontMetrics(const QFontMetrics &); ~QFontMetrics(); @@ -127,7 +127,7 @@ private: class Q_GUI_EXPORT QFontMetricsF { public: - QFontMetricsF(const QFont &); + explicit QFontMetricsF(const QFont &); QFontMetricsF(const QFont &, QPaintDevice *pd); QFontMetricsF(const QFontMetrics &); QFontMetricsF(const QFontMetricsF &); diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index 0dd0d99d2a..02fd921fac 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -2325,7 +2325,7 @@ void QTextCursor::insertImage(const QImage &image, const QString &name) } QString imageName = name; if (name.isEmpty()) - imageName = QString::number(image.serialNumber()); + imageName = QString::number(image.cacheKey()); d->priv->document()->addResource(QTextDocument::ImageResource, QUrl(imageName), image); QTextImageFormat format; format.setName(imageName); diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h index e4f4020461..c64420b000 100644 --- a/src/testlib/qtestcase.h +++ b/src/testlib/qtestcase.h @@ -264,38 +264,20 @@ namespace QTest template <typename T1, typename T2> bool qCompare(T1 const &, T2 const &, const char *, const char *, const char *, int); -#if defined(QT_COORD_TYPE) && (defined(Q_PROCESSOR_ARM) || defined(QT_NO_FPU) || defined(Q_OS_WINCE)) template <> - inline bool qCompare<qreal, float>(qreal const &t1, float const &t2, const char *actual, + inline bool qCompare<double, float>(double const &t1, float const &t2, const char *actual, const char *expected, const char *file, int line) { - return qCompare<qreal>(t1, qreal(t2), actual, expected, file, line); + return qCompare<qreal>(qreal(t1), qreal(t2), actual, expected, file, line); } template <> - inline bool qCompare<float, qreal>(float const &t1, qreal const &t2, const char *actual, + inline bool qCompare<float, double>(float const &t1, double const &t2, const char *actual, const char *expected, const char *file, int line) { - return qCompare<qreal>(qreal(t1), t2, actual, expected, file, line); + return qCompare<qreal>(qreal(t1), qreal(t2), actual, expected, file, line); } -#elif defined(QT_COORD_TYPE) || defined(Q_PROCESSOR_ARM) || defined(QT_NO_FPU) || defined(Q_OS_WINCE) - template <> - inline bool qCompare<qreal, double>(qreal const &t1, double const &t2, const char *actual, - const char *expected, const char *file, int line) - { - return qCompare<float>(float(t1), float(t2), actual, expected, file, line); - } - - template <> - inline bool qCompare<double, qreal>(double const &t1, qreal const &t2, const char *actual, - const char *expected, const char *file, int line) - { - return qCompare<float>(float(t1), float(t2), actual, expected, file, line); - } - -#endif - template <typename T> inline bool qCompare(const T *t1, const T *t2, const char *actual, const char *expected, const char *file, int line) diff --git a/src/testlib/qtestdata.h b/src/testlib/qtestdata.h index 22dae76167..8849b15ddb 100644 --- a/src/testlib/qtestdata.h +++ b/src/testlib/qtestdata.h @@ -89,6 +89,14 @@ inline QTestData &operator<<(QTestData &data, const char * value) return data; } +#ifdef QT_USE_QSTRINGBUILDER +template<typename A, typename B> +inline QTestData &operator<<(QTestData &data, const QStringBuilder<A, B> &value) +{ + return data << typename QConcatenable<QStringBuilder<A, B> >::ConvertTo(value); +} +#endif + QT_END_NAMESPACE QT_END_HEADER diff --git a/src/tools/moc/main.cpp b/src/tools/moc/main.cpp index 772df1feec..6f67a7dddf 100644 --- a/src/tools/moc/main.cpp +++ b/src/tools/moc/main.cpp @@ -159,7 +159,7 @@ int runMoc(int _argc, char **_argv) bool autoInclude = true; bool defaultInclude = true; Preprocessor pp; - Moc moc; + Moc moc(pp); pp.macros["Q_MOC_RUN"]; pp.macros["__cplusplus"]; QByteArray filename; diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 7b358c1ae8..4189c29de1 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -304,7 +304,9 @@ void Moc::parseFunctionArguments(FunctionDef *def) arg.rightType += lexem(); } arg.normalizedType = normalizeType(QByteArray(arg.type.name + ' ' + arg.rightType)); + arg.normalizedType = getTypeSubstitution(arg.normalizedType); arg.typeNameForCast = normalizeType(QByteArray(noRef(arg.type.name) + "(*)" + arg.rightType)); + arg.typeNameForCast = getTypeSubstitution(arg.typeNameForCast); if (test(EQ)) arg.isDefault = true; def->arguments += arg; @@ -414,6 +416,7 @@ bool Moc::parseFunction(FunctionDef *def, bool inMacro) } def->normalizedType = normalizeType(def->type.name); + def->normalizedType = getTypeSubstitution(def->normalizedType); if (!test(RPAREN)) { parseFunctionArguments(def); @@ -512,6 +515,7 @@ bool Moc::parseMaybeFunction(const ClassDef *cdef, FunctionDef *def) } def->normalizedType = normalizeType(def->type.name); + def->normalizedType = getTypeSubstitution(def->normalizedType); if (!test(RPAREN)) { parseFunctionArguments(def); @@ -968,6 +972,7 @@ void Moc::createPropertyDef(PropertyDef &propDef) QVariant. */ type = normalizeType(type); + type = getTypeSubstitution(type); if (type == "QMap") type = "QMap<QString,QVariant>"; else if (type == "QValueList") @@ -1081,7 +1086,6 @@ void Moc::parseProperty(ClassDef *def) createPropertyDef(propDef); next(RPAREN); - if(!propDef.notify.isEmpty()) def->notifyableProperties++; if (propDef.revision > 0) @@ -1244,7 +1248,8 @@ void Moc::parseInterfaces(ClassDef *def) } // resolve from classnames to interface ids for (int i = 0; i < iface.count(); ++i) { - const QByteArray iid = interface2IdMap.value(iface.at(i).className); + QByteArray className = getTypeSubstitution(iface.at(i).className); + QByteArray iid = interface2IdMap.value(className); if (iid.isEmpty()) error("Undefined interface"); @@ -1502,6 +1507,107 @@ void Moc::checkProperties(ClassDef *cdef) } } +QByteArray Moc::getSubstitution(const QByteArray &token) const +{ + Macros::ConstIterator it = preprocessor.macros.find(token); + if (it != preprocessor.macros.end() && it->symbols.count() == 1) { + // We can only handle substitutions that result in a single symbol + return it->symbols.at(0).lexem(); + } + + return QByteArray(); +} + +QByteArray Moc::getTokenSubstitution(const QByteArray &token) const +{ + QByteArray result = token; + + QSet<QByteArray> used; + + // Process substitution chain until no replacement exists + QByteArray substitution = getSubstitution(result); + while (!substitution.isEmpty()) { + used.insert(result); + result = substitution; + + if (used.contains(result)) { + break; + } + + substitution = getSubstitution(result); + } + + return result; +} + +QByteArray Moc::getWordSubstitution(const QByteArray &word) const +{ + QByteArray result; + + // A word can contain multiple components separated by '*' + int startIndex = 0; + do { + int index = word.indexOf('*', startIndex); + if (index == -1) { + result.append(getTokenSubstitution(word.mid(startIndex))); + } else { + result.append(getTokenSubstitution(word.mid(startIndex, (index - startIndex)))); + result.append('*'); + } + + startIndex = index + 1; + } while (startIndex != 0); + + return result; +} + +QByteArray Moc::getNameSubstitution(const QByteArray &name) const +{ + QByteArray result; + + // Parse multiple tokens in this name independently + int startIndex = 0; + do { + int index = name.indexOf(' ', startIndex); + if (index == -1) { + result.append(getWordSubstitution(name.mid(startIndex))); + } else { + result.append(getWordSubstitution(name.mid(startIndex, (index - startIndex)))); + result.append(' '); + } + + startIndex = index + 1; + } while (startIndex != 0); + + return result; +} + +QByteArray Moc::getTypeSubstitution(const QByteArray &typeName) const +{ + int index = typeName.indexOf('<'); + if (index != -1) { + QByteArray templateName = typeName.left(index); + + int lastIndex = typeName.lastIndexOf('>'); + if (lastIndex > index) { + QByteArray result = getNameSubstitution(templateName); + + // Parse the interior type independently + QByteArray parameter = typeName.mid(index + 1, (lastIndex - index - 1)); + QByteArray interior = getTypeSubstitution(parameter); + if (interior.endsWith('>')) { + interior.append(' '); + } + result.append('<').append(interior).append(typeName.mid(lastIndex)); + return result; + } else { + // Something is broken; return the input unmodified + return typeName; + } + } + + return getNameSubstitution(typeName); +} QT_END_NAMESPACE diff --git a/src/tools/moc/moc.h b/src/tools/moc/moc.h index aedb97b234..9e9225da0a 100644 --- a/src/tools/moc/moc.h +++ b/src/tools/moc/moc.h @@ -43,6 +43,7 @@ #define MOC_H #include "parser.h" +#include "preprocessor.h" #include <QStringList> #include <QMap> #include <QPair> @@ -197,12 +198,14 @@ struct NamespaceDef { class Moc : public Parser { public: - Moc() - : noInclude(false), generatedCode(false), mustIncludeQMetaTypeH(false), mustIncludeQPluginH(false) + Moc(Preprocessor &p) + : preprocessor(p), noInclude(false), generatedCode(false), + mustIncludeQMetaTypeH(false), mustIncludeQPluginH(false) {} QByteArray filename; + Preprocessor &preprocessor; bool noInclude; bool generatedCode; bool mustIncludeQMetaTypeH; @@ -260,6 +263,12 @@ public: void checkSuperClasses(ClassDef *def); void checkProperties(ClassDef* cdef); + + QByteArray getSubstitution(const QByteArray &token) const; + QByteArray getTokenSubstitution(const QByteArray &token) const; + QByteArray getWordSubstitution(const QByteArray &word) const; + QByteArray getNameSubstitution(const QByteArray &name) const; + QByteArray getTypeSubstitution(const QByteArray &typeName) const; }; inline QByteArray noRef(const QByteArray &type) diff --git a/src/tools/moc/moc.pro b/src/tools/moc/moc.pro index 3ee507855c..5c96c96a4c 100644 --- a/src/tools/moc/moc.pro +++ b/src/tools/moc/moc.pro @@ -13,6 +13,6 @@ HEADERS += qdatetime_p.h SOURCES += main.cpp include(../bootstrap/bootstrap.pri) -target.path=$$[QT_INSTALL_BINS] +target.path = $$[QT_HOST_BINS] INSTALLS += target load(qt_targets) diff --git a/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp index b31c47e7ad..dfe23983b7 100644 --- a/src/tools/rcc/rcc.cpp +++ b/src/tools/rcc/rcc.cpp @@ -681,7 +681,7 @@ bool RCCResourceLibrary::output(QIODevice &outDevice, QIODevice &errorDevice) m_errorDevice->write("Could not write footer\n"); return false; } - outDevice.write(m_out, m_out.size()); + outDevice.write(m_out.constData(), m_out.size()); return true; } diff --git a/src/tools/rcc/rcc.pro b/src/tools/rcc/rcc.pro index 6c78642406..e87ef605b9 100644 --- a/src/tools/rcc/rcc.pro +++ b/src/tools/rcc/rcc.pro @@ -11,6 +11,6 @@ HEADERS += ../../corelib/kernel/qcorecmdlineargs_p.h SOURCES += main.cpp include(../bootstrap/bootstrap.pri) -target.path=$$[QT_INSTALL_BINS] +target.path = $$[QT_HOST_BINS] INSTALLS += target load(qt_targets) diff --git a/src/tools/uic/cpp/cppwriteicondata.cpp b/src/tools/uic/cpp/cppwriteicondata.cpp index 39ce52f4b3..082961cfe6 100644 --- a/src/tools/uic/cpp/cppwriteicondata.cpp +++ b/src/tools/uic/cpp/cppwriteicondata.cpp @@ -176,8 +176,8 @@ void WriteIconData::writeImage(QTextStream &output, const QString &indent, void WriteIconData::writeImage(QIODevice &output, DomImage *image) { - QByteArray array = transformImageData(image->elementData()->text()); - output.write(array, array.size()); + const QByteArray array = transformImageData(image->elementData()->text()); + output.write(array.constData(), array.size()); } } // namespace CPP diff --git a/src/tools/uic/uic.pro b/src/tools/uic/uic.pro index 7a95db861f..0acc6e77c8 100644 --- a/src/tools/uic/uic.pro +++ b/src/tools/uic/uic.pro @@ -22,6 +22,6 @@ linux-g++-maemo { include(../bootstrap/bootstrap.pri) -target.path=$$[QT_INSTALL_BINS] +target.path = $$[QT_HOST_BINS] INSTALLS += target load(qt_targets) diff --git a/src/widgets/graphicsview/qgraphicssceneevent.h b/src/widgets/graphicsview/qgraphicssceneevent.h index be93c47476..95de435846 100644 --- a/src/widgets/graphicsview/qgraphicssceneevent.h +++ b/src/widgets/graphicsview/qgraphicssceneevent.h @@ -66,7 +66,7 @@ class QGraphicsSceneEventPrivate; class Q_WIDGETS_EXPORT QGraphicsSceneEvent : public QEvent { public: - QGraphicsSceneEvent(Type type); + explicit QGraphicsSceneEvent(Type type); ~QGraphicsSceneEvent(); QWidget *widget() const; @@ -84,7 +84,7 @@ class QGraphicsSceneMouseEventPrivate; class Q_WIDGETS_EXPORT QGraphicsSceneMouseEvent : public QGraphicsSceneEvent { public: - QGraphicsSceneMouseEvent(Type type = None); + explicit QGraphicsSceneMouseEvent(Type type = None); ~QGraphicsSceneMouseEvent(); QPointF pos() const; @@ -132,7 +132,7 @@ class QGraphicsSceneWheelEventPrivate; class Q_WIDGETS_EXPORT QGraphicsSceneWheelEvent : public QGraphicsSceneEvent { public: - QGraphicsSceneWheelEvent(Type type = None); + explicit QGraphicsSceneWheelEvent(Type type = None); ~QGraphicsSceneWheelEvent(); QPointF pos() const; @@ -167,7 +167,7 @@ class Q_WIDGETS_EXPORT QGraphicsSceneContextMenuEvent : public QGraphicsSceneEve public: enum Reason { Mouse, Keyboard, Other }; - QGraphicsSceneContextMenuEvent(Type type = None); + explicit QGraphicsSceneContextMenuEvent(Type type = None); ~QGraphicsSceneContextMenuEvent(); QPointF pos() const; @@ -194,7 +194,7 @@ class QGraphicsSceneHoverEventPrivate; class Q_WIDGETS_EXPORT QGraphicsSceneHoverEvent : public QGraphicsSceneEvent { public: - QGraphicsSceneHoverEvent(Type type = None); + explicit QGraphicsSceneHoverEvent(Type type = None); ~QGraphicsSceneHoverEvent(); QPointF pos() const; @@ -227,7 +227,7 @@ class QGraphicsSceneHelpEventPrivate; class Q_WIDGETS_EXPORT QGraphicsSceneHelpEvent : public QGraphicsSceneEvent { public: - QGraphicsSceneHelpEvent(Type type = None); + explicit QGraphicsSceneHelpEvent(Type type = None); ~QGraphicsSceneHelpEvent(); QPointF scenePos() const; @@ -245,7 +245,7 @@ class QGraphicsSceneDragDropEventPrivate; class Q_WIDGETS_EXPORT QGraphicsSceneDragDropEvent : public QGraphicsSceneEvent { public: - QGraphicsSceneDragDropEvent(Type type = None); + explicit QGraphicsSceneDragDropEvent(Type type = None); ~QGraphicsSceneDragDropEvent(); QPointF pos() const; diff --git a/src/widgets/kernel/qgesture.h b/src/widgets/kernel/qgesture.h index 8c412680b8..5e121def41 100644 --- a/src/widgets/kernel/qgesture.h +++ b/src/widgets/kernel/qgesture.h @@ -270,7 +270,7 @@ class QGestureEventPrivate; class Q_WIDGETS_EXPORT QGestureEvent : public QEvent { public: - QGestureEvent(const QList<QGesture *> &gestures); + explicit QGestureEvent(const QList<QGesture *> &gestures); ~QGestureEvent(); QList<QGesture *> gestures() const; diff --git a/src/widgets/kernel/qicon.cpp b/src/widgets/kernel/qicon.cpp index 4f244b1027..369e26c21e 100644 --- a/src/widgets/kernel/qicon.cpp +++ b/src/widgets/kernel/qicon.cpp @@ -616,7 +616,8 @@ QIcon::operator QVariant() const return QVariant(QVariant::Icon, this); } -/*! \obsolete +/*! \fn int QIcon::serialNumber() const + \obsolete Returns a number that identifies the contents of this QIcon object. Distinct QIcon objects can have @@ -633,11 +634,6 @@ QIcon::operator QVariant() const \sa QPixmap::serialNumber() */ -int QIcon::serialNumber() const -{ - return d ? d->serialNum : 0; -} - /*! Returns a number that identifies the contents of this QIcon object. Distinct QIcon objects can have the same key if diff --git a/src/widgets/kernel/qicon.h b/src/widgets/kernel/qicon.h index 7bef500946..c6e07ba3e2 100644 --- a/src/widgets/kernel/qicon.h +++ b/src/widgets/kernel/qicon.h @@ -94,7 +94,9 @@ public: bool isDetached() const; void detach(); - int serialNumber() const; +#if QT_DEPRECATED_SINCE(5, 0) + QT_DEPRECATED inline int serialNumber() const { return cacheKey() >> 32; } +#endif qint64 cacheKey() const; void addPixmap(const QPixmap &pixmap, Mode mode = Normal, State state = Off); diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp index 95fde4e4f6..766ca51ec3 100644 --- a/src/xml/dom/qdom.cpp +++ b/src/xml/dom/qdom.cpp @@ -5684,24 +5684,24 @@ static QByteArray encodeEntity(const QByteArray& str) QByteArray tmp(str); int len = tmp.size(); int i = 0; - const char* d = tmp.data(); + const char* d = tmp.constData(); while (i < len) { if (d[i] == '%'){ tmp.replace(i, 1, "<"); - d = tmp; + d = tmp.constData(); len += 4; i += 5; } else if (d[i] == '"') { tmp.replace(i, 1, """); - d = tmp; + d = tmp.constData(); len += 4; i += 5; } else if (d[i] == '&' && i + 1 < len && d[i+1] == '#') { // Dont encode < or " or &custom;. // Only encode character references tmp.replace(i, 1, "&"); - d = tmp; + d = tmp.constData(); len += 4; i += 5; } else { diff --git a/src/xml/sax/qxml.cpp b/src/xml/sax/qxml.cpp index 2488d27807..c2205edb40 100644 --- a/src/xml/sax/qxml.cpp +++ b/src/xml/sax/qxml.cpp @@ -1612,7 +1612,7 @@ QString QXmlInputSource::fromRawData(const QByteArray &data, bool beginning) d->encMapper = codec->makeDecoder(); } - QString input = d->encMapper->toUnicode(data, data.size()); + QString input = d->encMapper->toUnicode(data.constData(), data.size()); if (d->lookingForEncodingDecl) { d->encodingDeclChars += input; @@ -1633,9 +1633,9 @@ QString QXmlInputSource::fromRawData(const QByteArray &data, bool beginning) input.clear(); // prime the decoder with the data so far - d->encMapper->toUnicode(d->encodingDeclBytes, d->encodingDeclBytes.size()); + d->encMapper->toUnicode(d->encodingDeclBytes.constData(), d->encodingDeclBytes.size()); // now feed it the new data - input = d->encMapper->toUnicode(data, data.size()); + input = d->encMapper->toUnicode(data.constData(), data.size()); } } } |