Don't use _debug suffix to determine if a plugin is built in debug mode

The string based suffix check is fragile, and doesn't account for Qt
builds where the build is debug but we don't suffix the library.

The check was added in 27239f4fcfa6f64d60e7b79185ff413878152ebd, where
we started linking explicitly to the debug library in a framework,
in which case we could end up loading both the debug and release
Qt libraries into the same process if we loaded mismatched plugins.

However 7044409c878f100c005b76fc90717b4f71667f04 removed the explicit
linking, and nowadays we always link to the release version of the
framework library, and rely on DYLD_IMAGE_SUFFIX to switch to loading
the debug libraries, which applies globally to all libraries loaded.

This means we no longer need the _debug suffix check in the plugin
factory loader to account for the logic introduced initially in
27239f4fcfa6f64d60e7b79185ff413878152ebd.

And as we now have logic to avoid loading duplicate plugins in the
case of a debug-release-build we can safely remove the check.

Change-Id: I75685afa16a33aa41448f9a369dbefa8539418fd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 195d9f1ce7753a38c4dd871b981749017839227a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tor Arne Vestbø 2024-06-20 17:27:13 +02:00 committed by Qt Cherry-pick Bot
parent 1364db690a
commit 3852a6a779

View File

@ -313,20 +313,7 @@ inline void QFactoryLoaderPrivate::updateSinglePath(const QString &path)
for (const auto &dirEntry : plugins) {
const QString &fileName = dirEntry.fileName();
#ifdef Q_OS_DARWIN
const bool isDebugPlugin = fileName.endsWith("_debug.dylib"_L1);
const bool isDebugLibrary =
#ifdef QT_DEBUG
true;
#else
false;
#endif
// Skip mismatching plugins so that we don't end up loading both debug and release
// versions of the same Qt libraries (due to the plugin's dependencies).
if (isDebugPlugin != isDebugLibrary)
continue;
#elif defined(Q_PROCESSOR_X86)
#if defined(Q_PROCESSOR_X86)
if (fileName.endsWith(".avx2"_L1) || fileName.endsWith(".avx512"_L1)) {
// ignore AVX2-optimized file, we'll do a bait-and-switch to it later
continue;