From bb8aada627e23a7f7e23dfdb97d443f1b847086a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20M=C3=A4=C3=A4tt=C3=A4?= Date: Mon, 20 Mar 2023 08:17:52 +0200 Subject: Fix crash at exit when tracing The crash is caused by the cleanup sending trace messages when the plugin has already been destroyed. Add shutdown callback to the plugin to indicate this has happened. We can't use signals since that also generetes trace event. Pick-to: 6.5 Change-Id: I2e490fc51c2aaa97c240c1496a528a6ff6077bd0 Reviewed-by: Hatem ElKharashy Reviewed-by: Janne Koskinen --- src/corelib/tracing/qctf.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/corelib/tracing/qctf.cpp') diff --git a/src/corelib/tracing/qctf.cpp b/src/corelib/tracing/qctf.cpp index 1dafa582d91..00a196c926f 100644 --- a/src/corelib/tracing/qctf.cpp +++ b/src/corelib/tracing/qctf.cpp @@ -15,6 +15,7 @@ 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 defined(Q_OS_ANDROID) @@ -59,18 +60,13 @@ static bool loadPlugin(bool &retry) s_plugin = qobject_cast(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; } static bool initialize() { - if (s_prevent_recursion) + if (s_shutdown || s_prevent_recursion) return false; if (s_initialized || s_triedLoading) return s_initialized; -- cgit v1.2.3