-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
QFactoryLoader::instance(): don't fully parse static plugins' data
Commit d9766dd (Qt 5.12) replaced the use of the old binary JSON format with CBOR, which is more compact and standard, but requires actual parsing instead of just a quick size verification. For regular, loaded plugins, the metadata is stored in parsed QCborValue format, but for static plugins, we were re-parsing each staticplugin's metadata for every single call. This avoids a full parsing and only parses the CBOR header to find the IIDs (moc always outputs the IID first). Fixes: QTBUG-114253 Pick-to: 6.6 Change-Id: I8bd6bb457b9c42218247fffd179750ec6c9e3252 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
- Loading branch information
1 parent
58fc332
commit 4a432a7
Showing
7 changed files
with
204 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ endif() | |
|
||
add_subdirectory(plugin1) | ||
add_subdirectory(plugin2) | ||
add_subdirectory(staticplugin) | ||
add_subdirectory(test) |
14 changes: 14 additions & 0 deletions
14
tests/auto/corelib/plugin/qfactoryloader/staticplugin/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright (C) 2022 The Qt Company Ltd. | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
qt_internal_add_cmake_library(tst_qfactoryloader_staticplugin | ||
STATIC | ||
SOURCES | ||
main.cpp | ||
LIBRARIES | ||
Qt::Core | ||
) | ||
|
||
qt_autogen_tools_initial_setup(tst_qfactoryloader_staticplugin) | ||
|
||
target_compile_definitions(tst_qfactoryloader_staticplugin PRIVATE QT_STATICPLUGIN) |
22 changes: 22 additions & 0 deletions
22
tests/auto/corelib/plugin/qfactoryloader/staticplugin/main.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (C) 2018 Intel Corporation. | ||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 | ||
#include <QtPlugin> | ||
#include <QObject> | ||
|
||
class StaticPlugin1 : public QObject | ||
{ | ||
Q_OBJECT | ||
Q_PLUGIN_METADATA(IID "StaticPlugin1" FILE "plugin.json") | ||
public: | ||
StaticPlugin1() {} | ||
}; | ||
|
||
class StaticPlugin2 : public QObject | ||
{ | ||
Q_OBJECT | ||
Q_PLUGIN_METADATA(IID "StaticPlugin2" FILE "plugin.json") | ||
public: | ||
StaticPlugin2() {} | ||
}; | ||
|
||
#include "main.moc" |
3 changes: 3 additions & 0 deletions
3
tests/auto/corelib/plugin/qfactoryloader/staticplugin/plugin.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"Keys": [ "Value" ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters