From df31c25382b6d9e799a74c0d3f731f0cacc056e6 Mon Sep 17 00:00:00 2001 From: zeljan1 Date: Sat, 15 Feb 2025 17:36:19 +0100 Subject: [PATCH] Qt5,Qt6: Seem that QEventDestroy does not work anymore for qt5 and qt6. issue #41433 --- lcl/interfaces/qt5/qtwidgets.pas | 25 ++++++++++--------------- lcl/interfaces/qt6/qtwidgets.pas | 25 ++++++++++--------------- 2 files changed, 20 insertions(+), 30 deletions(-) diff --git a/lcl/interfaces/qt5/qtwidgets.pas b/lcl/interfaces/qt5/qtwidgets.pas index 5df74ebe83..46439598e7 100644 --- a/lcl/interfaces/qt5/qtwidgets.pas +++ b/lcl/interfaces/qt5/qtwidgets.pas @@ -671,7 +671,6 @@ type ScrollArea: TQtWindowArea; {$ENDIF} destructor Destroy; override; - procedure Destroyed; cdecl; override; procedure BeginUpdate; override; procedure EndUpdate; override; @@ -2381,7 +2380,17 @@ begin end; procedure TQtWidget.Destroyed; cdecl; +var + Msg: TLMessage; begin + //QEventDestroy does not trigger in Qt5 and Qt6 so we must finish here. + //see issue #41433. + if Assigned(LCLObject) then + begin + FillChar(Msg{%H-}, SizeOf(Msg), #0); + Msg.Msg := LM_DESTROY; + DeliverMessage(Msg); + end; Widget := nil; Release; end; @@ -7418,20 +7427,6 @@ begin inherited Destroy; end; -procedure TQtMainWindow.Destroyed; cdecl; -begin - //this is event from qt, must inform LCL about it. issue #41433 - //when non modal popup is shown over modal form and modal form = real popup parent - //if popup form, and modal form is closed on button close then qt releases - //popup form automatically, so all we have todo is inform LCL. - if Assigned(LCLObject) and (LCLObject.Parent = nil) and not IsMdiChild then - begin - Widget := nil; - SlotDestroy; - end else - inherited Destroyed; -end; - procedure TQtMainWindow.BeginUpdate; begin inherited BeginUpdate; diff --git a/lcl/interfaces/qt6/qtwidgets.pas b/lcl/interfaces/qt6/qtwidgets.pas index 0aee32b636..a424737872 100644 --- a/lcl/interfaces/qt6/qtwidgets.pas +++ b/lcl/interfaces/qt6/qtwidgets.pas @@ -669,7 +669,6 @@ type ScrollArea: TQtWindowArea; {$ENDIF} destructor Destroy; override; - procedure Destroyed; cdecl; override; procedure BeginUpdate; override; procedure EndUpdate; override; @@ -2378,7 +2377,17 @@ begin end; procedure TQtWidget.Destroyed; cdecl; +var + Msg: TLMessage; begin + //QEventDestroy does not trigger in Qt5 and Qt6 so we must finish here. + //see issue #41433. + if Assigned(LCLObject) then + begin + FillChar(Msg{%H-}, SizeOf(Msg), #0); + Msg.Msg := LM_DESTROY; + DeliverMessage(Msg); + end; Widget := nil; Release; end; @@ -7369,20 +7378,6 @@ begin inherited Destroy; end; -procedure TQtMainWindow.Destroyed; cdecl; -begin - //this is event from qt, must inform LCL about it. issue #41433 - //when non modal popup is shown over modal form and modal form = real popup parent - //if popup form, and modal form is closed on button close then qt releases - //popup form automatically, so all we have todo is inform LCL. - if Assigned(LCLObject) and (LCLObject.Parent = nil) and not IsMdiChild then - begin - Widget := nil; - SlotDestroy; - end else - inherited Destroyed; -end; - procedure TQtMainWindow.BeginUpdate; begin inherited BeginUpdate;