From 254e14a81708213312d8b64d73fbc1dfc362b0d0 Mon Sep 17 00:00:00 2001 From: aavit Date: Wed, 23 Mar 2011 13:40:50 +0100 Subject: Avoid repeatedly trying to load unloadable plugins, causing slowness In certain uncommon situations, where different Qt versions are used on the same system, the plugin caching optimization may identify a dll as a valid plugin, even though it will later fail to load. This fix will avoid that Qt repeatdly tries to reopen such dlls, something which caused a significant performance hit in these cases. E.g. where Qt would unsuccessfully try to load a number of KDE image format plugins for every image loading operation. Task-number: QTBUG-10066 Reviewed-by: thiago Reviewed-by: janarve --- src/corelib/plugin/qlibrary.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp index ecd1aac..80e927b 100644 --- a/src/corelib/plugin/qlibrary.cpp +++ b/src/corelib/plugin/qlibrary.cpp @@ -516,6 +516,8 @@ bool QLibraryPrivate::loadPlugin() libraryUnloadCount.ref(); return true; } + if (pluginState == IsNotAPlugin) + return false; if (load()) { instance = (QtPluginInstanceFunction)resolve("qt_plugin_instance"); #if defined(Q_OS_SYMBIAN) @@ -528,6 +530,9 @@ bool QLibraryPrivate::loadPlugin() #endif return instance; } + if (qt_debug_component()) + qWarning() << "QLibraryPrivate::loadPlugin failed on" << fileName << ":" << errorString; + pluginState = IsNotAPlugin; return false; } @@ -687,7 +692,7 @@ bool QLibraryPrivate::isPlugin(QSettings *settings) .arg((QT_VERSION & 0xff00) >> 8) .arg(QLIBRARY_AS_DEBUG ? QLatin1String("debug") : QLatin1String("false")) .arg(fileName); -#ifdef Q_WS_MAC +#ifdef Q_WS_MAC // On Mac, add the application arch to the reg key in order to // cache plugin information separately for each arch. This prevents // Qt from wrongly caching plugin load failures when the archs @@ -702,7 +707,7 @@ bool QLibraryPrivate::isPlugin(QSettings *settings) regkey += QLatin1String("-ppc"); #endif #endif // Q_WS_MAC - + QStringList reg; #ifndef QT_NO_SETTINGS if (!settings) { -- cgit v0.12