summaryrefslogtreecommitdiffstats
path: root/src/corelib/plugin/qfactoryloader.cpp
diff options
context:
space:
mode:
authorMorten Johan Sorvig <morten.sorvig@digia.com>2012-12-10 11:29:54 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-12-12 01:26:23 +0100
commit968b11737564572ef5939400ed70f281556d167b (patch)
treed2ae300d1c8eb008481e82ca2f934a3b4f7ef564 /src/corelib/plugin/qfactoryloader.cpp
parent4955cd8539dd23ad568daa1dad004677078d15c9 (diff)
Improve Cocoa platform plugin loading.
Loading both the debug and release version of the cocoa plugins causes the objective-c runtime to print "duplicate class definitions" warnings. Fix this by directing the plugin loader to only load one of the cocoa plugins if both are available. Implement this as a special case directly in QFactoryLoader. Define QT_NO_DEBUG_PLUGIN_CHECK to allow mixing debug and release builds. Task-number: QTBUG-28155 Change-Id: Ie1927b219cc501a821f91b7e4b56f0589e0acbf5 Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/plugin/qfactoryloader.cpp')
-rw-r--r--src/corelib/plugin/qfactoryloader.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp
index 75652b0902..aeb78e88b4 100644
--- a/src/corelib/plugin/qfactoryloader.cpp
+++ b/src/corelib/plugin/qfactoryloader.cpp
@@ -126,9 +126,30 @@ void QFactoryLoader::update()
QStringList plugins = QDir(path).entryList(QDir::Files);
QLibraryPrivate *library = 0;
+
+#ifdef Q_OS_MAC
+ // Loading both the debug and release version of the cocoa plugins causes the objective-c runtime
+ // to print "duplicate class definitions" warnings. Detect if QFactoryLoader is about to load both,
+ // skip one of them (below).
+ //
+ // ### FIXME find a proper solution
+ //
+ const bool isLoadingDebugAndReleaseCocoa = plugins.contains("libqcocoa_debug.dylib") && plugins.contains("libqcocoa.dylib");
+#endif
for (int j = 0; j < plugins.count(); ++j) {
QString fileName = QDir::cleanPath(path + QLatin1Char('/') + plugins.at(j));
+#ifdef Q_OS_MAC
+ if (isLoadingDebugAndReleaseCocoa) {
+#ifdef QT_DEBUG
+ if (fileName.contains(QStringLiteral("libqcocoa.dylib")))
+ continue; // Skip release plugin in debug mode
+#else
+ if (fileName.contains(QStringLiteral("libqcocoa_debug.dylib")))
+ continue; // Skip debug plugin in release mode
+#endif
+ }
+#endif
if (qt_debug_component()) {
qDebug() << "QFactoryLoader::QFactoryLoader() looking at" << fileName;
}