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;