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>
This commit is contained in:
parent
57d08f6c09
commit
b64d720b28
@ -49,6 +49,7 @@
|
|||||||
#include <qjsondocument.h>
|
#include <qjsondocument.h>
|
||||||
#include <qmap.h>
|
#include <qmap.h>
|
||||||
#include <qmutex.h>
|
#include <qmutex.h>
|
||||||
|
#include <qoperatingsystemversion.h>
|
||||||
#include <qstringlist.h>
|
#include <qstringlist.h>
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
@ -65,17 +66,22 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
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
|
#ifdef QT_NO_DEBUG
|
||||||
# define QLIBRARY_AS_DEBUG false
|
static constexpr bool QtBuildIsDebug = false;
|
||||||
#else
|
#else
|
||||||
# define QLIBRARY_AS_DEBUG true
|
static constexpr bool QtBuildIsDebug = true;
|
||||||
#endif
|
#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
|
\class QLibrary
|
||||||
@ -783,12 +789,10 @@ void QLibraryPrivate::updatePluginState()
|
|||||||
.arg((qt_version&0xff00) >> 8)
|
.arg((qt_version&0xff00) >> 8)
|
||||||
.arg(qt_version&0xff)
|
.arg(qt_version&0xff)
|
||||||
.arg(debug ? QLatin1String("debug") : QLatin1String("release"));
|
.arg(debug ? QLatin1String("debug") : QLatin1String("release"));
|
||||||
#ifndef QT_NO_DEBUG_PLUGIN_CHECK
|
} else if (PluginMustMatchQtDebug && debug != QtBuildIsDebug) {
|
||||||
} else if (debug != QLIBRARY_AS_DEBUG) {
|
|
||||||
//don't issue a qWarning since we will hopefully find a non-debug? --Sam
|
//don't issue a qWarning since we will hopefully find a non-debug? --Sam
|
||||||
errorString = QLibrary::tr("The plugin '%1' uses incompatible Qt library."
|
errorString = QLibrary::tr("The plugin '%1' uses incompatible Qt library."
|
||||||
" (Cannot mix debug and release libraries.)").arg(fileName);
|
" (Cannot mix debug and release libraries.)").arg(fileName);
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
pluginState = IsAPlugin;
|
pluginState = IsAPlugin;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user