From 0bca49a007d60413fa82f3eca132f6d2600220f7 Mon Sep 17 00:00:00 2001 From: Robert Griebl Date: Wed, 17 Aug 2022 20:14:17 +0200 Subject: Fix the internal IntentHandler map getting corrupted on closing apps std::remove_if() on a QMap should result in a compile-time error, but it somehow doesn't. Instead the erase(remove_if()) algorithm leaves a corrupted QMap. This is especially noticeable in single-process mode, where the wrong intent handlers are being called after closing any single application, which registered IntentHandlers before. This bug was introduced while fixing clazy warnings. Change-Id: I144c051591ce8564e2653402d12bb926ef32eb76 Reviewed-by: Dominik Holland (cherry picked from commit 4507e6f17c640d9e044a4b87ea4b84dda3c5b8ad) Reviewed-by: Qt Cherry-pick Bot --- src/intent-client-lib/intentclient.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/intent-client-lib/intentclient.cpp b/src/intent-client-lib/intentclient.cpp index 08fbd92f..1148fbb9 100644 --- a/src/intent-client-lib/intentclient.cpp +++ b/src/intent-client-lib/intentclient.cpp @@ -143,9 +143,7 @@ void IntentClient::registerHandler(IntentHandler *handler) void IntentClient::unregisterHandler(IntentHandler *handler) { - m_handlers.erase(std::remove_if(m_handlers.begin(), m_handlers.end(), - [handler](const auto &h) { return h == handler; }), - m_handlers.end()); + m_handlers.removeIf([handler](auto it) { return it.value() == handler; }); } /*! \qmlmethod IntentRequest IntentClient::sendIntentRequest(string intentId, var parameters) -- cgit v1.2.1