summaryrefslogtreecommitdiffstats
path: root/src/corelib/plugin
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2021-09-20 16:06:27 -0700
committerThiago Macieira <thiago.macieira@intel.com>2021-10-18 14:58:58 -0700
commitb64d720b2870c9b7bbf051328b4914172f46dee6 (patch)
tree31b6b6293e1a38b1df060ad489cc8fe52bc58e0a /src/corelib/plugin
parent57d08f6c0909ed0873f2fa35a0298d713fa98a9d (diff)
QPluginLoader: use constexpr variables for detecting debug plugins
For MSVC it's clear that the plugin and Qt must match, since they would be linking to different runtime assemblies otherwise. For all other systems, including MinGW on Windows, there's no such thing. But we insist on MinGW debug-and-release builds matching. Change-Id: I3eb1bd30e0124f89a052fffd16a6aa52c7f8b9c0 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/plugin')
-rw-r--r--src/corelib/plugin/qlibrary.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp
index e18a5080f5..432b232d27 100644
--- a/src/corelib/plugin/qlibrary.cpp
+++ b/src/corelib/plugin/qlibrary.cpp
@@ -49,6 +49,7 @@
#include <qjsondocument.h>
#include <qmap.h>
#include <qmutex.h>
+#include <qoperatingsystemversion.h>
#include <qstringlist.h>
#ifdef Q_OS_MAC
@@ -65,17 +66,22 @@
QT_BEGIN_NAMESPACE
+// On Unix systema and on Windows with MinGW, we can mix and match debug and
+// release plugins without problems. (unless compiled in debug-and-release mode
+// - why?)
+static constexpr bool PluginMustMatchQtDebug =
+ QOperatingSystemVersion::currentType() == QOperatingSystemVersion::Windows
+#if defined(Q_CC_MINGW)
+ && QT_CONFIG(debug_and_release)
+#endif
+ ;
+
#ifdef QT_NO_DEBUG
-# define QLIBRARY_AS_DEBUG false
+static constexpr bool QtBuildIsDebug = false;
#else
-# define QLIBRARY_AS_DEBUG true
+static constexpr bool QtBuildIsDebug = true;
#endif
-#if defined(Q_OS_UNIX) || (defined(Q_CC_MINGW) && !QT_CONFIG(debug_and_release))
-// We don't use separate debug and release libs on UNIX, so we want
-// to allow loading plugins, regardless of how they were built.
-# define QT_NO_DEBUG_PLUGIN_CHECK
-#endif
/*!
\class QLibrary
@@ -783,12 +789,10 @@ void QLibraryPrivate::updatePluginState()
.arg((qt_version&0xff00) >> 8)
.arg(qt_version&0xff)
.arg(debug ? QLatin1String("debug") : QLatin1String("release"));
-#ifndef QT_NO_DEBUG_PLUGIN_CHECK
- } else if (debug != QLIBRARY_AS_DEBUG) {
+ } else if (PluginMustMatchQtDebug && debug != QtBuildIsDebug) {
//don't issue a qWarning since we will hopefully find a non-debug? --Sam
errorString = QLibrary::tr("The plugin '%1' uses incompatible Qt library."
" (Cannot mix debug and release libraries.)").arg(fileName);
-#endif
} else {
pluginState = IsAPlugin;
}