From 6010559863e32f10901f2b315057b262d78e1d31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=BDeljan=20Rikalo?= Date: Tue, 3 Jun 2025 18:47:18 +0200 Subject: [PATCH] Qt5,Qt6: fixed crash when QAction is destroyed before it's events are detached. issue #41618 (cherry picked from commit 5ca9daf80f8a57cb9f6af05adfb6d0a0671eb5d1) Co-authored-by: zeljan1 --- lcl/interfaces/qt5/qtwidgets.pas | 9 +++++---- lcl/interfaces/qt6/qtwidgets.pas | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lcl/interfaces/qt5/qtwidgets.pas b/lcl/interfaces/qt5/qtwidgets.pas index ecedef5c7e..13d28e2a99 100644 --- a/lcl/interfaces/qt5/qtwidgets.pas +++ b/lcl/interfaces/qt5/qtwidgets.pas @@ -16605,10 +16605,6 @@ begin FActions.Free; end; - if Assigned(FActionHandle) then - QAction_Destroy(FActionHandle); - FActionHandle := nil; - inherited Destroy; end; @@ -16662,6 +16658,11 @@ begin QMenu_hook_destroy(FAboutToHideHook); FAboutToHideHook := nil; end; + + if Assigned(FActionHandle) then + QAction_Destroy(FActionHandle); + FActionHandle := nil; + inherited DetachEvents; end; diff --git a/lcl/interfaces/qt6/qtwidgets.pas b/lcl/interfaces/qt6/qtwidgets.pas index 505f95d7e5..81c03233ca 100644 --- a/lcl/interfaces/qt6/qtwidgets.pas +++ b/lcl/interfaces/qt6/qtwidgets.pas @@ -16519,10 +16519,6 @@ begin FActions.Free; end; - if Assigned(FActionHandle) then - QAction_Destroy(FActionHandle); - FActionHandle := nil; - inherited Destroy; end; @@ -16576,6 +16572,11 @@ begin QMenu_hook_destroy(FAboutToHideHook); FAboutToHideHook := nil; end; + + if Assigned(FActionHandle) then + QAction_Destroy(FActionHandle); + FActionHandle := nil; + inherited DetachEvents; end;