diff options
Diffstat (limited to 'src/corelib/plugin')
-rw-r--r-- | src/corelib/plugin/qfactoryloader.cpp | 16 | ||||
-rw-r--r-- | src/corelib/plugin/qlibrary.cpp | 38 | ||||
-rw-r--r-- | src/corelib/plugin/qlibrary_p.h | 4 | ||||
-rw-r--r-- | src/corelib/plugin/qlibrary_unix.cpp | 41 | ||||
-rw-r--r-- | src/corelib/plugin/qplugin.h | 32 | ||||
-rw-r--r-- | src/corelib/plugin/qplugin_p.h | 6 | ||||
-rw-r--r-- | src/corelib/plugin/qpluginloader.cpp | 11 | ||||
-rw-r--r-- | src/corelib/plugin/quuid.cpp | 16 | ||||
-rw-r--r-- | src/corelib/plugin/quuid.h | 44 |
9 files changed, 137 insertions, 71 deletions
diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp index 35c64180d4..18f10c9b43 100644 --- a/src/corelib/plugin/qfactoryloader.cpp +++ b/src/corelib/plugin/qfactoryloader.cpp @@ -170,7 +170,7 @@ public: Q_GLOBAL_STATIC(QList<QFactoryLoader *>, qt_factory_loaders) -Q_GLOBAL_STATIC_WITH_ARGS(QMutex, qt_factoryloader_mutex, (QMutex::Recursive)) +Q_GLOBAL_STATIC(QRecursiveMutex, qt_factoryloader_mutex) QFactoryLoaderPrivate::~QFactoryLoaderPrivate() { @@ -193,7 +193,11 @@ void QFactoryLoader::update() continue; d->loadedPaths << pluginDir; +#ifdef Q_OS_ANDROID + QString path = pluginDir; +#else QString path = pluginDir + d->suffix; +#endif if (qt_debug_component()) qDebug() << "QFactoryLoader::QFactoryLoader() checking directory path" << path << "..."; @@ -202,8 +206,10 @@ void QFactoryLoader::update() continue; QStringList plugins = QDir(path).entryList( -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) QStringList(QStringLiteral("*.dll")), +#elif defined(Q_OS_ANDROID) + QStringList(QLatin1String("libplugins_%1_*.so").arg(d->suffix)), #endif QDir::Files); QLibraryPrivate *library = 0; @@ -239,7 +245,7 @@ void QFactoryLoader::update() library = QLibraryPrivate::findOrCreate(QFileInfo(fileName).canonicalFilePath()); if (!library->isPlugin()) { if (qt_debug_component()) { - qDebug() << library->errorString << endl + qDebug() << library->errorString << Qt::endl << " not a plugin"; } library->release(); @@ -339,6 +345,10 @@ QFactoryLoader::QFactoryLoader(const char *iid, #if QT_CONFIG(library) d->cs = cs; d->suffix = suffix; +# ifdef Q_OS_ANDROID + if (!d->suffix.isEmpty() && d->suffix.at(0) == QLatin1Char('/')) + d->suffix.remove(0, 1); +# endif QMutexLocker locker(qt_factoryloader_mutex()); update(); diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp index 0e32776c71..eeaa3c18ec 100644 --- a/src/corelib/plugin/qlibrary.cpp +++ b/src/corelib/plugin/qlibrary.cpp @@ -74,7 +74,7 @@ QT_BEGIN_NAMESPACE # define QLIBRARY_AS_DEBUG true #endif -#if defined(Q_OS_UNIX) +#if defined(Q_OS_UNIX) || (defined(Q_CC_MINGW) && !QT_CONFIG(debug_and_release)) // We don't use separate debug and release libs on UNIX, so we want // to allow loading plugins, regardless of how they were built. # define QT_NO_DEBUG_PLUGIN_CHECK @@ -241,8 +241,8 @@ static bool findPatternUnloaded(const QString &library, QLibraryPrivate *lib) if (lib) lib->errorString = file.errorString(); if (qt_debug_component()) { - qWarning("%s: %s", QFile::encodeName(library).constData(), - qPrintable(QSystemError::stdString())); + qWarning("%s: %ls", QFile::encodeName(library).constData(), + qUtf16Printable(QSystemError::stdString())); } return false; } @@ -275,7 +275,7 @@ static bool findPatternUnloaded(const QString &library, QLibraryPrivate *lib) int r = QElfParser().parse(filedata, fdlen, library, lib, &pos, &fdlen); if (r == QElfParser::Corrupt || r == QElfParser::NotElf) { if (lib && qt_debug_component()) { - qWarning("QElfParser: %s",qPrintable(lib->errorString)); + qWarning("QElfParser: %ls", qUtf16Printable(lib->errorString)); } return false; } else if (r == QElfParser::QtMetaDataSection) { @@ -292,7 +292,7 @@ static bool findPatternUnloaded(const QString &library, QLibraryPrivate *lib) int r = QMachOParser::parse(filedata, fdlen, library, &errorString, &pos, &fdlen); if (r == QMachOParser::NotSuitable) { if (qt_debug_component()) - qWarning("QMachOParser: %s", qPrintable(errorString)); + qWarning("QMachOParser: %ls", qUtf16Printable(errorString)); if (lib) lib->errorString = errorString; return false; @@ -319,8 +319,8 @@ static bool findPatternUnloaded(const QString &library, QLibraryPrivate *lib) QString errMsg; QJsonDocument doc = qJsonFromRawLibraryMetaData(data, fdlen, &errMsg); if (doc.isNull()) { - qWarning("Found invalid metadata in lib %s: %s", - qPrintable(library), qPrintable(errMsg)); + qWarning("Found invalid metadata in lib %ls: %ls", + qUtf16Printable(library), qUtf16Printable(errMsg)); } else { lib->metaData = doc.object(); if (qt_debug_component()) @@ -356,11 +356,11 @@ static void installCoverageTool(QLibraryPrivate *libPrivate) if (qt_debug_component()) { if (ret >= 0) { - qDebug("coverage data for %s registered", - qPrintable(libPrivate->fileName)); + qDebug("coverage data for %ls registered", + qUtf16Printable(libPrivate->fileName)); } else { - qWarning("could not register %s: error %d; coverage data may be incomplete", - qPrintable(libPrivate->fileName), + qWarning("could not register %ls: error %d; coverage data may be incomplete", + qUtf16Printable(libPrivate->fileName), ret); } } @@ -405,10 +405,10 @@ inline void QLibraryStore::cleanup() LibraryMap::Iterator it = data->libraryMap.begin(); for (; it != data->libraryMap.end(); ++it) { QLibraryPrivate *lib = it.value(); - if (lib->libraryRefCount.load() == 1) { - if (lib->libraryUnloadCount.load() > 0) { + if (lib->libraryRefCount.loadRelaxed() == 1) { + if (lib->libraryUnloadCount.loadRelaxed() > 0) { Q_ASSERT(lib->pHnd); - lib->libraryUnloadCount.store(1); + lib->libraryUnloadCount.storeRelaxed(1); #ifdef __GLIBC__ // glibc has a bug in unloading from global destructors // see https://bugzilla.novell.com/show_bug.cgi?id=622977 @@ -428,7 +428,7 @@ inline void QLibraryStore::cleanup() for (QLibraryPrivate *lib : qAsConst(data->libraryMap)) { if (lib) qDebug() << "On QtCore unload," << lib->fileName << "was leaked, with" - << lib->libraryRefCount.load() << "users"; + << lib->libraryRefCount.loadRelaxed() << "users"; } } @@ -487,7 +487,7 @@ inline void QLibraryStore::releaseLibrary(QLibraryPrivate *lib) } // no one else is using - Q_ASSERT(lib->libraryUnloadCount.load() == 0); + Q_ASSERT(lib->libraryUnloadCount.loadRelaxed() == 0); if (Q_LIKELY(data) && !lib->fileName.isEmpty()) { QLibraryPrivate *that = data->libraryMap.take(lib->fileName); @@ -501,7 +501,7 @@ QLibraryPrivate::QLibraryPrivate(const QString &canonicalFileName, const QString : pHnd(0), fileName(canonicalFileName), fullVersion(version), instance(0), libraryRefCount(0), libraryUnloadCount(0), pluginState(MightBeAPlugin) { - loadHintsInt.store(loadHints); + loadHintsInt.storeRelaxed(loadHints); if (canonicalFileName.isEmpty()) errorString = QLibrary::tr("The shared library was not found."); } @@ -522,7 +522,7 @@ void QLibraryPrivate::mergeLoadHints(QLibrary::LoadHints lh) if (pHnd) return; - loadHintsInt.store(lh); + loadHintsInt.storeRelaxed(lh); } QFunctionPointer QLibraryPrivate::resolve(const char *symbol) @@ -575,7 +575,7 @@ bool QLibraryPrivate::unload(UnloadFlag flag) { if (!pHnd) return false; - if (libraryUnloadCount.load() > 0 && !libraryUnloadCount.deref()) { // only unload if ALL QLibrary instance wanted to + if (libraryUnloadCount.loadRelaxed() > 0 && !libraryUnloadCount.deref()) { // only unload if ALL QLibrary instance wanted to delete inst.data(); if (flag == NoUnloadSys || unload_sys()) { if (qt_debug_component()) diff --git a/src/corelib/plugin/qlibrary_p.h b/src/corelib/plugin/qlibrary_p.h index 3f650501c8..db5afac98e 100644 --- a/src/corelib/plugin/qlibrary_p.h +++ b/src/corelib/plugin/qlibrary_p.h @@ -92,11 +92,11 @@ public: QFunctionPointer resolve(const char *); QLibrary::LoadHints loadHints() const - { return QLibrary::LoadHints(loadHintsInt.load()); } + { return QLibrary::LoadHints(loadHintsInt.loadRelaxed()); } void setLoadHints(QLibrary::LoadHints lh); static QLibraryPrivate *findOrCreate(const QString &fileName, const QString &version = QString(), - QLibrary::LoadHints loadHints = 0); + QLibrary::LoadHints loadHints = nullptr); static QStringList suffixes_sys(const QString &fullVersion); static QStringList prefixes_sys(); diff --git a/src/corelib/plugin/qlibrary_unix.cpp b/src/corelib/plugin/qlibrary_unix.cpp index e03814984c..f0de1010d7 100644 --- a/src/corelib/plugin/qlibrary_unix.cpp +++ b/src/corelib/plugin/qlibrary_unix.cpp @@ -52,6 +52,10 @@ # include <private/qcore_mac_p.h> #endif +#ifdef Q_OS_ANDROID +# include <private/qjnihelpers_p.h> +#endif + QT_BEGIN_NAMESPACE static QString qdlerror() @@ -77,14 +81,14 @@ QStringList QLibraryPrivate::suffixes_sys(const QString& fullVersion) // .so is preferred. # if defined(__ia64) if (!fullVersion.isEmpty()) { - suffixes << QString::fromLatin1(".so.%1").arg(fullVersion); + suffixes << QLatin1String(".so.%1").arg(fullVersion); } else { suffixes << QLatin1String(".so"); } # endif if (!fullVersion.isEmpty()) { - suffixes << QString::fromLatin1(".sl.%1").arg(fullVersion); - suffixes << QString::fromLatin1(".%1").arg(fullVersion); + suffixes << QLatin1String(".sl.%1").arg(fullVersion); + suffixes << QLatin1String(".%1").arg(fullVersion); } else { suffixes << QLatin1String(".sl"); } @@ -93,15 +97,18 @@ QStringList QLibraryPrivate::suffixes_sys(const QString& fullVersion) #else if (!fullVersion.isEmpty()) { - suffixes << QString::fromLatin1(".so.%1").arg(fullVersion); + suffixes << QLatin1String(".so.%1").arg(fullVersion); } else { suffixes << QLatin1String(".so"); +# ifdef Q_OS_ANDROID + suffixes << QStringLiteral(LIBS_SUFFIX); +# endif } #endif # ifdef Q_OS_MAC if (!fullVersion.isEmpty()) { - suffixes << QString::fromLatin1(".%1.bundle").arg(fullVersion); - suffixes << QString::fromLatin1(".%1.dylib").arg(fullVersion); + suffixes << QLatin1String(".%1.bundle").arg(fullVersion); + suffixes << QLatin1String(".%1.dylib").arg(fullVersion); } else { suffixes << QLatin1String(".bundle") << QLatin1String(".dylib"); } @@ -157,9 +164,12 @@ bool QLibraryPrivate::load_sys() // Do not unload the library during dlclose(). Consequently, the // library's specific static variables are not reinitialized if the // library is reloaded with dlopen() at a later time. -#if defined(RTLD_NODELETE) && !defined(Q_OS_ANDROID) +#if defined(RTLD_NODELETE) if (loadHints & QLibrary::PreventUnloadHint) { - dlFlags |= RTLD_NODELETE; +# ifdef Q_OS_ANDROID // RTLD_NODELETE flag is supported by Android 23+ + if (QtAndroidPrivate::androidSdkVersion() > 22) +# endif + dlFlags |= RTLD_NODELETE; } #endif @@ -219,7 +229,22 @@ bool QLibraryPrivate::load_sys() } else { attempt = path + prefixes.at(prefix) + name + suffixes.at(suffix); } + pHnd = dlopen(QFile::encodeName(attempt), dlFlags); +#ifdef Q_OS_ANDROID + if (!pHnd) { + auto attemptFromBundle = attempt; + pHnd = dlopen(QFile::encodeName(attemptFromBundle.replace(QLatin1Char('/'), QLatin1Char('_'))), dlFlags); + } + if (pHnd) { + using JniOnLoadPtr = jint (*)(JavaVM *vm, void *reserved); + JniOnLoadPtr jniOnLoad = reinterpret_cast<JniOnLoadPtr>(dlsym(pHnd, "JNI_OnLoad")); + if (jniOnLoad && jniOnLoad(QtAndroidPrivate::javaVM(), nullptr) == JNI_ERR) { + dlclose(pHnd); + pHnd = nullptr; + } + } +#endif if (!pHnd && fileName.startsWith(QLatin1Char('/')) && QFile::exists(attempt)) { // We only want to continue if dlopen failed due to that the shared library did not exist. diff --git a/src/corelib/plugin/qplugin.h b/src/corelib/plugin/qplugin.h index 676b5047d6..c176155c28 100644 --- a/src/corelib/plugin/qplugin.h +++ b/src/corelib/plugin/qplugin.h @@ -75,7 +75,12 @@ typedef QObject *(*QtPluginInstanceFunction)(); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) typedef const char *(*QtPluginMetaDataFunction)(); #else -typedef QPair<const uchar *, size_t> (*QtPluginMetaDataFunction)(); +struct QPluginMetaData +{ + const uchar *data; + size_t size; +}; +typedef QPluginMetaData (*QtPluginMetaDataFunction)(); #endif @@ -84,12 +89,14 @@ struct Q_CORE_EXPORT QStaticPlugin #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) public: constexpr QStaticPlugin(QtPluginInstanceFunction i, QtPluginMetaDataFunction m) - : instance(i), rawMetaData(m().first), rawMetaDataSize(m().second) + : instance(i), rawMetaData(m().data), rawMetaDataSize(m().size) + {} QtPluginInstanceFunction instance; private: // ### Qt 6: revise, as this is not standard-layout const void *rawMetaData; - qsizetype rawMetaDataSize + qsizetype rawMetaDataSize; +public: #elif !defined(Q_QDOC) // Note: This struct is initialized using an initializer list. // As such, it cannot have any new constructors or variables. @@ -154,6 +161,16 @@ void Q_CORE_EXPORT qRegisterStaticPluginFunction(QStaticPlugin staticPlugin); #if defined(QT_STATICPLUGIN) +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +# define QT_MOC_EXPORT_PLUGIN(PLUGINCLASS, PLUGINCLASSNAME) \ + static QT_PREPEND_NAMESPACE(QObject) *qt_plugin_instance_##PLUGINCLASSNAME() \ + Q_PLUGIN_INSTANCE(PLUGINCLASS) \ + static QPluginMetaData qt_plugin_query_metadata_##PLUGINCLASSNAME() \ + { return { qt_pluginMetaData, sizeof qt_pluginMetaData }; } \ + const QT_PREPEND_NAMESPACE(QStaticPlugin) qt_static_plugin_##PLUGINCLASSNAME() { \ + return { qt_plugin_instance_##PLUGINCLASSNAME, qt_plugin_query_metadata_##PLUGINCLASSNAME}; \ + } +#else # define QT_MOC_EXPORT_PLUGIN(PLUGINCLASS, PLUGINCLASSNAME) \ static QT_PREPEND_NAMESPACE(QObject) *qt_plugin_instance_##PLUGINCLASSNAME() \ Q_PLUGIN_INSTANCE(PLUGINCLASS) \ @@ -162,13 +179,15 @@ void Q_CORE_EXPORT qRegisterStaticPluginFunction(QStaticPlugin staticPlugin); QT_PREPEND_NAMESPACE(QStaticPlugin) plugin = { qt_plugin_instance_##PLUGINCLASSNAME, qt_plugin_query_metadata_##PLUGINCLASSNAME}; \ return plugin; \ } +#endif -#elif QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +#else +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) # define QT_MOC_EXPORT_PLUGIN(PLUGINCLASS, PLUGINCLASSNAME) \ Q_EXTERN_C Q_DECL_EXPORT \ - auto qt_plugin_query_metadata() \ - { return qMakePair<const void *, size_t>(qt_pluginMetaData, sizeof qt_pluginMetaData); } \ + QPluginMetaData qt_plugin_query_metadata() \ + { return { qt_pluginMetaData, sizeof qt_pluginMetaData }; } \ Q_EXTERN_C Q_DECL_EXPORT QT_PREPEND_NAMESPACE(QObject) *qt_plugin_instance() \ Q_PLUGIN_INSTANCE(PLUGINCLASS) @@ -183,6 +202,7 @@ void Q_CORE_EXPORT qRegisterStaticPluginFunction(QStaticPlugin staticPlugin); #endif +#endif #define Q_EXPORT_PLUGIN(PLUGIN) \ Q_EXPORT_PLUGIN2(PLUGIN, PLUGIN) diff --git a/src/corelib/plugin/qplugin_p.h b/src/corelib/plugin/qplugin_p.h index 717129268b..ce45ebf700 100644 --- a/src/corelib/plugin/qplugin_p.h +++ b/src/corelib/plugin/qplugin_p.h @@ -60,7 +60,8 @@ enum class QtPluginMetaDataKeys { Requirements, IID, ClassName, - MetaData + MetaData, + URI }; // F(IntKey, StringKey, Description) @@ -68,7 +69,8 @@ enum class QtPluginMetaDataKeys { #define QT_PLUGIN_FOREACH_METADATA(F) \ F(QtPluginMetaDataKeys::IID, "IID", "Plugin's Interface ID") \ F(QtPluginMetaDataKeys::ClassName, "className", "Plugin class name") \ - F(QtPluginMetaDataKeys::MetaData, "MetaData", "Other meta data") + F(QtPluginMetaDataKeys::MetaData, "MetaData", "Other meta data") \ + F(QtPluginMetaDataKeys::URI, "URI", "Plugin URI") QT_END_NAMESPACE diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp index 4e0c3a511b..c2443dbdda 100644 --- a/src/corelib/plugin/qpluginloader.cpp +++ b/src/corelib/plugin/qpluginloader.cpp @@ -305,12 +305,21 @@ static QString locatePlugin(const QString& fileName) paths.append(fileName.left(slash)); // don't include the '/' } else { paths = QCoreApplication::libraryPaths(); - paths.prepend(QStringLiteral(".")); // search in current dir first } for (const QString &path : qAsConst(paths)) { for (const QString &prefix : qAsConst(prefixes)) { for (const QString &suffix : qAsConst(suffixes)) { +#ifdef Q_OS_ANDROID + { + QString pluginPath = basePath + prefix + baseName + suffix; + const QString fn = path + QLatin1String("/lib") + pluginPath.replace(QLatin1Char('/'), QLatin1Char('_')); + if (debug) + qDebug() << "Trying..." << fn; + if (QFileInfo(fn).isFile()) + return fn; + } +#endif const QString fn = path + QLatin1Char('/') + basePath + prefix + baseName + suffix; if (debug) qDebug() << "Trying..." << fn; diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index 8bb5e1463a..83873edf6f 100644 --- a/src/corelib/plugin/quuid.cpp +++ b/src/corelib/plugin/quuid.cpp @@ -397,7 +397,7 @@ QUuid::QUuid(const QString &text) \sa toString(), QUuid() */ -QUuid QUuid::fromString(QStringView text) Q_DECL_NOTHROW +QUuid QUuid::fromString(QStringView text) noexcept { if (text.size() > MaxStringUuidLength) text = text.left(MaxStringUuidLength); // text.truncate(MaxStringUuidLength); @@ -427,7 +427,7 @@ QUuid QUuid::fromString(QStringView text) Q_DECL_NOTHROW \sa toString(), QUuid() */ -QUuid QUuid::fromString(QLatin1String text) Q_DECL_NOTHROW +QUuid QUuid::fromString(QLatin1String text) noexcept { if (Q_UNLIKELY(text.size() < MaxStringUuidLength - 2 || (text.front() == QLatin1Char('{') && text.size() < MaxStringUuidLength - 1))) { @@ -864,7 +864,7 @@ QDataStream &operator>>(QDataStream &s, QUuid &id) Returns \c true if this is the null UUID {00000000-0000-0000-0000-000000000000}; otherwise returns \c false. */ -bool QUuid::isNull() const Q_DECL_NOTHROW +bool QUuid::isNull() const noexcept { return data4[0] == 0 && data4[1] == 0 && data4[2] == 0 && data4[3] == 0 && data4[4] == 0 && data4[5] == 0 && data4[6] == 0 && data4[7] == 0 && @@ -913,7 +913,7 @@ bool QUuid::isNull() const Q_DECL_NOTHROW \sa version() */ -QUuid::Variant QUuid::variant() const Q_DECL_NOTHROW +QUuid::Variant QUuid::variant() const noexcept { if (isNull()) return VarUnknown; @@ -934,7 +934,7 @@ QUuid::Variant QUuid::variant() const Q_DECL_NOTHROW \sa variant() */ -QUuid::Version QUuid::version() const Q_DECL_NOTHROW +QUuid::Version QUuid::version() const noexcept { // Check the 4 MSB of data3 Version ver = (Version)(data3>>12); @@ -957,7 +957,7 @@ QUuid::Version QUuid::version() const Q_DECL_NOTHROW \sa variant() */ -bool QUuid::operator<(const QUuid &other) const Q_DECL_NOTHROW +bool QUuid::operator<(const QUuid &other) const noexcept { if (variant() != other.variant()) return variant() < other.variant(); @@ -984,7 +984,7 @@ bool QUuid::operator<(const QUuid &other) const Q_DECL_NOTHROW \sa variant() */ -bool QUuid::operator>(const QUuid &other) const Q_DECL_NOTHROW +bool QUuid::operator>(const QUuid &other) const noexcept { return other < *this; } @@ -1089,7 +1089,7 @@ QDebug operator<<(QDebug dbg, const QUuid &id) \relates QUuid Returns a hash of the UUID \a uuid, using \a seed to seed the calculation. */ -uint qHash(const QUuid &uuid, uint seed) Q_DECL_NOTHROW +uint qHash(const QUuid &uuid, uint seed) noexcept { return uuid.data1 ^ uuid.data2 ^ (uuid.data3 << 16) ^ ((uuid.data4[0] << 24) | (uuid.data4[1] << 16) | (uuid.data4[2] << 8) | uuid.data4[3]) diff --git a/src/corelib/plugin/quuid.h b/src/corelib/plugin/quuid.h index 08a1843640..713ca070c8 100644 --- a/src/corelib/plugin/quuid.h +++ b/src/corelib/plugin/quuid.h @@ -93,13 +93,13 @@ public: #if defined(Q_COMPILER_UNIFORM_INIT) && !defined(Q_CLANG_QDOC) - Q_DECL_CONSTEXPR QUuid() Q_DECL_NOTHROW : data1(0), data2(0), data3(0), data4{0,0,0,0,0,0,0,0} {} + Q_DECL_CONSTEXPR QUuid() noexcept : data1(0), data2(0), data3(0), data4{0,0,0,0,0,0,0,0} {} Q_DECL_CONSTEXPR QUuid(uint l, ushort w1, ushort w2, uchar b1, uchar b2, uchar b3, - uchar b4, uchar b5, uchar b6, uchar b7, uchar b8) Q_DECL_NOTHROW + uchar b4, uchar b5, uchar b6, uchar b7, uchar b8) noexcept : data1(l), data2(w1), data3(w2), data4{b1, b2, b3, b4, b5, b6, b7, b8} {} #else - QUuid() Q_DECL_NOTHROW + QUuid() noexcept { data1 = 0; data2 = 0; @@ -107,7 +107,7 @@ public: for(int i = 0; i < 8; i++) data4[i] = 0; } - QUuid(uint l, ushort w1, ushort w2, uchar b1, uchar b2, uchar b3, uchar b4, uchar b5, uchar b6, uchar b7, uchar b8) Q_DECL_NOTHROW + QUuid(uint l, ushort w1, ushort w2, uchar b1, uchar b2, uchar b3, uchar b4, uchar b5, uchar b6, uchar b7, uchar b8) noexcept { data1 = l; data2 = w1; @@ -124,8 +124,8 @@ public: #endif QUuid(const QString &); - static QUuid fromString(QStringView string) Q_DECL_NOTHROW; - static QUuid fromString(QLatin1String string) Q_DECL_NOTHROW; + static QUuid fromString(QStringView string) noexcept; + static QUuid fromString(QLatin1String string) noexcept; QUuid(const char *); QString toString() const; QString toString(StringFormat mode) const; // ### Qt6: merge with previous @@ -134,9 +134,9 @@ public: QByteArray toByteArray(StringFormat mode) const; // ### Qt6: merge with previous QByteArray toRfc4122() const; static QUuid fromRfc4122(const QByteArray &); - bool isNull() const Q_DECL_NOTHROW; + bool isNull() const noexcept; - Q_DECL_RELAXED_CONSTEXPR bool operator==(const QUuid &orig) const Q_DECL_NOTHROW + Q_DECL_RELAXED_CONSTEXPR bool operator==(const QUuid &orig) const noexcept { if (data1 != orig.data1 || data2 != orig.data2 || data3 != orig.data3) @@ -149,24 +149,24 @@ public: return true; } - Q_DECL_RELAXED_CONSTEXPR bool operator!=(const QUuid &orig) const Q_DECL_NOTHROW + Q_DECL_RELAXED_CONSTEXPR bool operator!=(const QUuid &orig) const noexcept { return !(*this == orig); } - bool operator<(const QUuid &other) const Q_DECL_NOTHROW; - bool operator>(const QUuid &other) const Q_DECL_NOTHROW; + bool operator<(const QUuid &other) const noexcept; + bool operator>(const QUuid &other) const noexcept; #if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC) // On Windows we have a type GUID that is used by the platform API, so we // provide convenience operators to cast from and to this type. #if defined(Q_COMPILER_UNIFORM_INIT) && !defined(Q_CLANG_QDOC) - Q_DECL_CONSTEXPR QUuid(const GUID &guid) Q_DECL_NOTHROW + Q_DECL_CONSTEXPR QUuid(const GUID &guid) noexcept : data1(guid.Data1), data2(guid.Data2), data3(guid.Data3), data4{guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]} {} #else - QUuid(const GUID &guid) Q_DECL_NOTHROW + QUuid(const GUID &guid) noexcept { data1 = guid.Data1; data2 = guid.Data2; @@ -176,24 +176,24 @@ public: } #endif - Q_DECL_RELAXED_CONSTEXPR QUuid &operator=(const GUID &guid) Q_DECL_NOTHROW + Q_DECL_RELAXED_CONSTEXPR QUuid &operator=(const GUID &guid) noexcept { *this = QUuid(guid); return *this; } - Q_DECL_RELAXED_CONSTEXPR operator GUID() const Q_DECL_NOTHROW + Q_DECL_RELAXED_CONSTEXPR operator GUID() const noexcept { GUID guid = { data1, data2, data3, { data4[0], data4[1], data4[2], data4[3], data4[4], data4[5], data4[6], data4[7] } }; return guid; } - Q_DECL_RELAXED_CONSTEXPR bool operator==(const GUID &guid) const Q_DECL_NOTHROW + Q_DECL_RELAXED_CONSTEXPR bool operator==(const GUID &guid) const noexcept { return *this == QUuid(guid); } - Q_DECL_RELAXED_CONSTEXPR bool operator!=(const GUID &guid) const Q_DECL_NOTHROW + Q_DECL_RELAXED_CONSTEXPR bool operator!=(const GUID &guid) const noexcept { return !(*this == guid); } @@ -216,8 +216,8 @@ public: } - QUuid::Variant variant() const Q_DECL_NOTHROW; - QUuid::Version version() const Q_DECL_NOTHROW; + QUuid::Variant variant() const noexcept; + QUuid::Version version() const noexcept; #if defined(Q_OS_DARWIN) || defined(Q_CLANG_QDOC) static QUuid fromCFUUID(CFUUIDRef uuid); @@ -243,11 +243,11 @@ Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QUuid &); Q_CORE_EXPORT QDebug operator<<(QDebug, const QUuid &); #endif -Q_CORE_EXPORT uint qHash(const QUuid &uuid, uint seed = 0) Q_DECL_NOTHROW; +Q_CORE_EXPORT uint qHash(const QUuid &uuid, uint seed = 0) noexcept; -inline bool operator<=(const QUuid &lhs, const QUuid &rhs) Q_DECL_NOTHROW +inline bool operator<=(const QUuid &lhs, const QUuid &rhs) noexcept { return !(rhs < lhs); } -inline bool operator>=(const QUuid &lhs, const QUuid &rhs) Q_DECL_NOTHROW +inline bool operator>=(const QUuid &lhs, const QUuid &rhs) noexcept { return !(lhs < rhs); } QT_END_NAMESPACE |