QCoreApplication: move the QRecursiveMutex into QCoreApplicationData
There's no need for it to be a global, if the data isn't either. I have a vague recollection of the data also being globals back in the day... (they used to be plain QStringList pointers). Change-Id: Ie5f1a71d0b20a0195822fffd992101c94824a07f Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit a314e4b98513d4b5cd89d05e74f93c2b16ebc168) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
a2792a934f
commit
cad8c1e6a7
@ -385,6 +385,7 @@ struct QCoreApplicationData
|
|||||||
#if QT_CONFIG(library)
|
#if QT_CONFIG(library)
|
||||||
std::unique_ptr<QStringList> app_libpaths;
|
std::unique_ptr<QStringList> app_libpaths;
|
||||||
std::unique_ptr<QStringList> manual_libpaths;
|
std::unique_ptr<QStringList> manual_libpaths;
|
||||||
|
QRecursiveMutex libraryPathMutex; // protects this block
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -2913,9 +2914,6 @@ void QCoreApplication::requestPermission(const QPermission &requestedPermission,
|
|||||||
#endif // QT_CONFIG(permissions)
|
#endif // QT_CONFIG(permissions)
|
||||||
|
|
||||||
#if QT_CONFIG(library)
|
#if QT_CONFIG(library)
|
||||||
|
|
||||||
Q_GLOBAL_STATIC(QRecursiveMutex, libraryPathMutex)
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Returns a list of paths that the application will search when
|
Returns a list of paths that the application will search when
|
||||||
dynamically loading libraries.
|
dynamically loading libraries.
|
||||||
@ -2947,7 +2945,7 @@ Q_GLOBAL_STATIC(QRecursiveMutex, libraryPathMutex)
|
|||||||
*/
|
*/
|
||||||
QStringList QCoreApplication::libraryPaths()
|
QStringList QCoreApplication::libraryPaths()
|
||||||
{
|
{
|
||||||
QMutexLocker locker(libraryPathMutex());
|
QMutexLocker locker(&coreappdata->libraryPathMutex);
|
||||||
return libraryPathsLocked();
|
return libraryPathsLocked();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3027,7 +3025,8 @@ QStringList QCoreApplication::libraryPathsLocked()
|
|||||||
*/
|
*/
|
||||||
void QCoreApplication::setLibraryPaths(const QStringList &paths)
|
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.
|
// 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
|
// 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())
|
if (canonicalPath.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QMutexLocker locker(libraryPathMutex());
|
QCoreApplicationData *d = coreappdata;
|
||||||
|
QMutexLocker locker(&d->libraryPathMutex);
|
||||||
|
|
||||||
QStringList *libpaths = coreappdata()->manual_libpaths.get();
|
QStringList *libpaths = coreappdata()->manual_libpaths.get();
|
||||||
if (libpaths) {
|
if (libpaths) {
|
||||||
@ -3108,7 +3108,8 @@ void QCoreApplication::removeLibraryPath(const QString &path)
|
|||||||
if (canonicalPath.isEmpty())
|
if (canonicalPath.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QMutexLocker locker(libraryPathMutex());
|
QCoreApplicationData *d = coreappdata;
|
||||||
|
QMutexLocker locker(&d->libraryPathMutex);
|
||||||
|
|
||||||
QStringList *libpaths = coreappdata()->manual_libpaths.get();
|
QStringList *libpaths = coreappdata()->manual_libpaths.get();
|
||||||
if (libpaths) {
|
if (libpaths) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user