diff options
Diffstat (limited to 'src/corelib/tracing/qctf.cpp')
-rw-r--r-- | src/corelib/tracing/qctf.cpp | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/src/corelib/tracing/qctf.cpp b/src/corelib/tracing/qctf.cpp index 1dafa582d9..ff81d0a678 100644 --- a/src/corelib/tracing/qctf.cpp +++ b/src/corelib/tracing/qctf.cpp @@ -7,6 +7,7 @@ #include <qpluginloader.h> #include <qfileinfo.h> #include <qdir.h> +#include <qjsonarray.h> #include "qctf_p.h" @@ -15,8 +16,11 @@ QT_BEGIN_NAMESPACE static bool s_initialized = false; static bool s_triedLoading = false; static bool s_prevent_recursion = false; +static bool s_shutdown = false; static QCtfLib* s_plugin = nullptr; +#if QT_CONFIG(library) && defined(QT_SHARED) + #if defined(Q_OS_ANDROID) static QString findPlugin(const QString &plugin) { @@ -59,18 +63,37 @@ static bool loadPlugin(bool &retry) s_plugin = qobject_cast<QCtfLib *>(loader.instance()); if (!s_plugin) return false; - QObject *obj = loader.instance(); - if (obj) { - QObject::connect(obj, &QObject::destroyed, []() { - s_plugin = nullptr; - }); - } + s_plugin->shutdown(&s_shutdown); return true; } +#else + +#define QCtfPluginIID QStringLiteral("org.qt-project.Qt.QCtfLib") + +static bool loadPlugin(bool &retry) +{ + retry = false; + const auto &plugins = QPluginLoader::staticPlugins(); + for (const auto &plugin : plugins) { + const auto json = plugin.metaData(); + const auto IID = json[QStringLiteral("IID")]; + if (IID.toString() == QCtfPluginIID) { + s_plugin = qobject_cast<QCtfLib *>(plugin.instance()); + if (!s_plugin) + return false; + s_plugin->shutdown(&s_shutdown); + return true; + } + } + return false; +} + +#endif + static bool initialize() { - if (s_prevent_recursion) + if (s_shutdown || s_prevent_recursion) return false; if (s_initialized || s_triedLoading) return s_initialized; @@ -117,3 +140,5 @@ QCtfTracePointPrivate *_initialize_tracepoint(const QCtfTracePointEvent &point) } QT_END_NAMESPACE + +#include "moc_qctf_p.cpp" |