diff options
author | Jan-Arve Sæther <jan-arve.saether@nokia.com> | 2009-08-21 09:12:43 (GMT) |
---|---|---|
committer | Jan-Arve Sæther <jan-arve.saether@nokia.com> | 2009-08-21 13:20:10 (GMT) |
commit | bf417fc0347467092dfd12a72ed8177524b473d4 (patch) | |
tree | 39c1bf49396e40830e505936cb9f73c2270c04ac /src/corelib/plugin | |
parent | 00ba962d428dcdff70fcde74a9e5cb316545cef6 (diff) | |
download | Qt-bf417fc0347467092dfd12a72ed8177524b473d4.zip Qt-bf417fc0347467092dfd12a72ed8177524b473d4.tar.gz Qt-bf417fc0347467092dfd12a72ed8177524b473d4.tar.bz2 |
Speed up plugin loading by not constructing a new QSettings each time.
This should benefit the platforms with slow QSettings, esp. Linux.
Task-number: 243398
Reviewed-by: brad
Diffstat (limited to 'src/corelib/plugin')
-rw-r--r-- | src/corelib/plugin/qlibrary.cpp | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp index ea8882f..f784622 100644 --- a/src/corelib/plugin/qlibrary.cpp +++ b/src/corelib/plugin/qlibrary.cpp @@ -416,7 +416,23 @@ static bool qt_unix_query(const QString &library, uint *version, bool *debug, QB #endif // Q_OS_UNIX && !Q_OS_MAC && !defined(QT_NO_PLUGIN_CHECK) typedef QMap<QString, QLibraryPrivate*> LibraryMap; -Q_GLOBAL_STATIC(LibraryMap, libraryMap) + +struct LibraryData { + LibraryData() : settings(0) { } + ~LibraryData() { + delete settings; + } + + QSettings *settings; + LibraryMap libraryMap; +}; + +Q_GLOBAL_STATIC(LibraryData, libraryData) + +static LibraryMap *libraryMap() +{ + return &(libraryData()->libraryMap); +} QLibraryPrivate::QLibraryPrivate(const QString &canonicalFileName, const QString &version) :pHnd(0), fileName(canonicalFileName), fullVersion(version), instance(0), qt_version(0), @@ -597,10 +613,12 @@ bool QLibraryPrivate::isPlugin(QSettings *settings) .arg(fileName); QStringList reg; #ifndef QT_NO_SETTINGS - bool madeSettings = false; if (!settings) { - settings = new QSettings(QSettings::UserScope, QLatin1String("Trolltech")); - madeSettings = true; + settings = libraryData()->settings; + if (!settings) { + settings = new QSettings(QSettings::UserScope, QLatin1String("Trolltech")); + libraryData()->settings = settings; + } } reg = settings->value(regkey).toStringList(); #endif @@ -679,10 +697,6 @@ bool QLibraryPrivate::isPlugin(QSettings *settings) settings->setValue(regkey, queried); #endif } -#ifndef QT_NO_SETTINGS - if (madeSettings) - delete settings; -#endif if (!success) { if (errorString.isEmpty()){ |