diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 984619668d6..9a240263410 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -385,6 +385,7 @@ struct QCoreApplicationData #if QT_CONFIG(library) std::unique_ptr app_libpaths; std::unique_ptr manual_libpaths; + QRecursiveMutex libraryPathMutex; // protects this block #endif }; @@ -2913,9 +2914,6 @@ void QCoreApplication::requestPermission(const QPermission &requestedPermission, #endif // QT_CONFIG(permissions) #if QT_CONFIG(library) - -Q_GLOBAL_STATIC(QRecursiveMutex, libraryPathMutex) - /*! Returns a list of paths that the application will search when dynamically loading libraries. @@ -2947,7 +2945,7 @@ Q_GLOBAL_STATIC(QRecursiveMutex, libraryPathMutex) */ QStringList QCoreApplication::libraryPaths() { - QMutexLocker locker(libraryPathMutex()); + QMutexLocker locker(&coreappdata->libraryPathMutex); return libraryPathsLocked(); } @@ -3027,7 +3025,8 @@ QStringList QCoreApplication::libraryPathsLocked() */ void QCoreApplication::setLibraryPaths(const QStringList &paths) { - QMutexLocker locker(libraryPathMutex()); + QCoreApplicationData *d = coreappdata; + QMutexLocker locker(&d->libraryPathMutex); // setLibraryPaths() is considered a "remove everything and then add some new ones" operation. // When the application is constructed it should still amend the paths. So we keep the originals @@ -3069,7 +3068,8 @@ void QCoreApplication::addLibraryPath(const QString &path) if (canonicalPath.isEmpty()) return; - QMutexLocker locker(libraryPathMutex()); + QCoreApplicationData *d = coreappdata; + QMutexLocker locker(&d->libraryPathMutex); QStringList *libpaths = coreappdata()->manual_libpaths.get(); if (libpaths) { @@ -3108,7 +3108,8 @@ void QCoreApplication::removeLibraryPath(const QString &path) if (canonicalPath.isEmpty()) return; - QMutexLocker locker(libraryPathMutex()); + QCoreApplicationData *d = coreappdata; + QMutexLocker locker(&d->libraryPathMutex); QStringList *libpaths = coreappdata()->manual_libpaths.get(); if (libpaths) {