QFactoryLoader: Clarify how we track the prioritized library for a key

Assigning to a variable named `previous` to promote a library to be the
current/prioritized library is needlessly obfuscated.

Amends 6675e8c942c2f9797d66269368c729c5556528c2.

Change-Id: Ibdd48cbb5daba60c231f9f71133c3b58d32f7781
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit 67bf3f9625c50a2af2d79d85247c1eee5b727682)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tor Arne Vestbø 2024-06-20 15:16:01 +02:00 committed by Qt Cherry-pick Bot
parent ffb0a15ea4
commit 1a9f4e8413

View File

@ -368,13 +368,13 @@ inline void QFactoryLoaderPrivate::updateSinglePath(const QString &path)
// whereas the new one has a Qt version that fits
// better
constexpr int QtVersionNoPatch = QT_VERSION_CHECK(QT_VERSION_MAJOR, QT_VERSION_MINOR, 0);
QLibraryPrivate *&previous = keyMap[key];
QLibraryPrivate *&keyMapEntry = keyMap[key];
int prev_qt_version = 0;
if (previous)
prev_qt_version = int(previous->metaData.value(QtPluginMetaDataKeys::QtVersion).toInteger());
if (keyMapEntry)
prev_qt_version = int(keyMapEntry->metaData.value(QtPluginMetaDataKeys::QtVersion).toInteger());
int qt_version = int(library->metaData.value(QtPluginMetaDataKeys::QtVersion).toInteger());
if (!previous || (prev_qt_version > QtVersionNoPatch && qt_version <= QtVersionNoPatch)) {
previous = library.get(); // we WILL .release()
if (!keyMapEntry || (prev_qt_version > QtVersionNoPatch && qt_version <= QtVersionNoPatch)) {
keyMapEntry = library.get(); // we WILL .release()
++keyUsageCount;
}
}