mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-02 12:20:38 +02:00
Qt5, Qt6: fixed showing and destroying popup window with popup parent modal form. issue #41433
This commit is contained in:
parent
5df0a8f05a
commit
740f63fe4c
@ -671,7 +671,7 @@ type
|
|||||||
ScrollArea: TQtWindowArea;
|
ScrollArea: TQtWindowArea;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
procedure Destroyed; cdecl; override;
|
||||||
procedure BeginUpdate; override;
|
procedure BeginUpdate; override;
|
||||||
procedure EndUpdate; override;
|
procedure EndUpdate; override;
|
||||||
|
|
||||||
@ -713,8 +713,9 @@ type
|
|||||||
property Blocked: Boolean read FBlocked write FBlocked;
|
property Blocked: Boolean read FBlocked write FBlocked;
|
||||||
property IsFrameWindow: Boolean read FIsFrameWindow write FIsFrameWindow; {check if our LCLObject is TCustomFrame}
|
property IsFrameWindow: Boolean read FIsFrameWindow write FIsFrameWindow; {check if our LCLObject is TCustomFrame}
|
||||||
property FirstPaintEvent: boolean read FFirstPaintEvent write FFirstPaintEvent; {only for x11 - if firstpaintevent arrived we are 100% sure that frame is 100% accurate}
|
property FirstPaintEvent: boolean read FFirstPaintEvent write FFirstPaintEvent; {only for x11 - if firstpaintevent arrived we are 100% sure that frame is 100% accurate}
|
||||||
property ShowOnTaskBar: Boolean read FShowOnTaskBar;
|
|
||||||
property MenuBar: TQtMenuBar read FMenuBar;
|
property MenuBar: TQtMenuBar read FMenuBar;
|
||||||
|
property PopupParent: QWidgetH read FPopupParent;
|
||||||
|
property ShowOnTaskBar: Boolean read FShowOnTaskBar;
|
||||||
public
|
public
|
||||||
function WinIDNeeded: boolean; override;
|
function WinIDNeeded: boolean; override;
|
||||||
procedure AttachEvents; override;
|
procedure AttachEvents; override;
|
||||||
@ -2973,15 +2974,15 @@ end;
|
|||||||
Params: None
|
Params: None
|
||||||
Returns: Nothing
|
Returns: Nothing
|
||||||
|
|
||||||
Note: LCL uses LM_CLOSEQUERY to set the form visibility and if we don<EFBFBD>t send this
|
Note: LCL uses LM_CLOSEQUERY to set the form visibility and if we don't send this
|
||||||
message, you won<EFBFBD>t be able to show a form twice.
|
message, you won't be able to show a form twice.
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
function TQtWidget.SlotClose: Boolean; cdecl;
|
function TQtWidget.SlotClose: Boolean; cdecl;
|
||||||
var
|
var
|
||||||
Msg : TLMessage;
|
Msg : TLMessage;
|
||||||
begin
|
begin
|
||||||
{$ifdef VerboseQt}
|
{$ifdef VerboseQt}
|
||||||
WriteLn('TQtWidget.SlotClose');
|
WriteLn('TQtWidget.SlotClose ',dbgsName(LCLObject));
|
||||||
{$endif}
|
{$endif}
|
||||||
FillChar(Msg{%H-}, SizeOf(Msg), 0);
|
FillChar(Msg{%H-}, SizeOf(Msg), 0);
|
||||||
|
|
||||||
@ -3004,7 +3005,7 @@ var
|
|||||||
Msg: TLMessage;
|
Msg: TLMessage;
|
||||||
begin
|
begin
|
||||||
{$ifdef VerboseQt}
|
{$ifdef VerboseQt}
|
||||||
WriteLn('TQtWidget.SlotDestroy');
|
WriteLn('TQtWidget.SlotDestroy ',dbgsName(LCLObject));
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
FillChar(Msg{%H-}, SizeOf(Msg), #0);
|
FillChar(Msg{%H-}, SizeOf(Msg), #0);
|
||||||
@ -7417,6 +7418,20 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
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;
|
procedure TQtMainWindow.BeginUpdate;
|
||||||
begin
|
begin
|
||||||
inherited BeginUpdate;
|
inherited BeginUpdate;
|
||||||
|
@ -259,6 +259,9 @@ end;
|
|||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
class procedure TQtWSWinControl.DestroyHandle(const AWinControl: TWinControl);
|
class procedure TQtWSWinControl.DestroyHandle(const AWinControl: TWinControl);
|
||||||
begin
|
begin
|
||||||
|
if not WSCheckHandleAllocated(AWinControl, 'DestroyHandle') then
|
||||||
|
Exit;
|
||||||
|
if QtWidgetSet.IsValidHandle(AWinControl.Handle) then
|
||||||
TQtWidget(AWinControl.Handle).Release;
|
TQtWidget(AWinControl.Handle).Release;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -629,7 +629,9 @@ begin
|
|||||||
APopupParent := TCustomForm(AWinControl).GetRealPopupParent;
|
APopupParent := TCustomForm(AWinControl).GetRealPopupParent;
|
||||||
if (APopupParent <> nil) then
|
if (APopupParent <> nil) then
|
||||||
begin
|
begin
|
||||||
Widget.setParent(TQtWidget(APopupParent.Handle).Widget);
|
//attach destroy event to PopupParent.Handle.Widget via signal on Widget
|
||||||
|
//use setRealPopupParent, issue #41433
|
||||||
|
Widget.setRealPopupParent(TQtWidget(APopupParent.Handle).Widget);
|
||||||
Widget.setWindowFlags(Widget.windowFlags or QtDialog); // issue #41241
|
Widget.setWindowFlags(Widget.windowFlags or QtDialog); // issue #41241
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -644,6 +646,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
Widget.setVisible(AWinControl.HandleObjectShouldBeVisible);
|
Widget.setVisible(AWinControl.HandleObjectShouldBeVisible);
|
||||||
|
if not AWinControl.HandleObjectShouldBeVisible then
|
||||||
|
begin
|
||||||
|
// issue #41433
|
||||||
|
if Widget.PopupParent <> nil then
|
||||||
|
Widget.setRealPopupParent(nil);
|
||||||
|
end;
|
||||||
Widget.EndUpdate;
|
Widget.EndUpdate;
|
||||||
|
|
||||||
{$IFDEF HASX11}
|
{$IFDEF HASX11}
|
||||||
|
@ -669,6 +669,7 @@ type
|
|||||||
ScrollArea: TQtWindowArea;
|
ScrollArea: TQtWindowArea;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
procedure Destroyed; cdecl; override;
|
||||||
|
|
||||||
procedure BeginUpdate; override;
|
procedure BeginUpdate; override;
|
||||||
procedure EndUpdate; override;
|
procedure EndUpdate; override;
|
||||||
@ -713,6 +714,7 @@ type
|
|||||||
property IsFrameWindow: Boolean read FIsFrameWindow write FIsFrameWindow; {check if our LCLObject is TCustomFrame}
|
property IsFrameWindow: Boolean read FIsFrameWindow write FIsFrameWindow; {check if our LCLObject is TCustomFrame}
|
||||||
property FirstPaintEvent: boolean read FFirstPaintEvent write FFirstPaintEvent; {only for x11 - if firstpaintevent arrived we are 100% sure that frame is 100% accurate}
|
property FirstPaintEvent: boolean read FFirstPaintEvent write FFirstPaintEvent; {only for x11 - if firstpaintevent arrived we are 100% sure that frame is 100% accurate}
|
||||||
property MenuBar: TQtMenuBar read FMenuBar;
|
property MenuBar: TQtMenuBar read FMenuBar;
|
||||||
|
property PopupParent: QWidgetH read FPopupParent;
|
||||||
property ShowOnTaskBar: Boolean read FShowOnTaskBar;
|
property ShowOnTaskBar: Boolean read FShowOnTaskBar;
|
||||||
public
|
public
|
||||||
function WinIDNeeded: boolean; override;
|
function WinIDNeeded: boolean; override;
|
||||||
@ -2969,15 +2971,15 @@ end;
|
|||||||
Params: None
|
Params: None
|
||||||
Returns: Nothing
|
Returns: Nothing
|
||||||
|
|
||||||
Note: LCL uses LM_CLOSEQUERY to set the form visibility and if we don<EFBFBD>t send this
|
Note: LCL uses LM_CLOSEQUERY to set the form visibility and if we don't send this
|
||||||
message, you won<EFBFBD>t be able to show a form twice.
|
message, you won't be able to show a form twice.
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
function TQtWidget.SlotClose: Boolean; cdecl;
|
function TQtWidget.SlotClose: Boolean; cdecl;
|
||||||
var
|
var
|
||||||
Msg : TLMessage;
|
Msg : TLMessage;
|
||||||
begin
|
begin
|
||||||
{$ifdef VerboseQt}
|
{$ifdef VerboseQt}
|
||||||
WriteLn('TQtWidget.SlotClose');
|
WriteLn('TQtWidget.SlotClose ',dbgsName(LCLObject));
|
||||||
{$endif}
|
{$endif}
|
||||||
FillChar(Msg{%H-}, SizeOf(Msg), 0);
|
FillChar(Msg{%H-}, SizeOf(Msg), 0);
|
||||||
|
|
||||||
@ -3000,7 +3002,7 @@ var
|
|||||||
Msg: TLMessage;
|
Msg: TLMessage;
|
||||||
begin
|
begin
|
||||||
{$ifdef VerboseQt}
|
{$ifdef VerboseQt}
|
||||||
WriteLn('TQtWidget.SlotDestroy');
|
WriteLn('TQtWidget.SlotDestroy ',dbgsName(LCLObject));
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
FillChar(Msg{%H-}, SizeOf(Msg), #0);
|
FillChar(Msg{%H-}, SizeOf(Msg), #0);
|
||||||
@ -7367,6 +7369,20 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
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;
|
procedure TQtMainWindow.BeginUpdate;
|
||||||
begin
|
begin
|
||||||
inherited BeginUpdate;
|
inherited BeginUpdate;
|
||||||
|
@ -257,6 +257,9 @@ end;
|
|||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
class procedure TQtWSWinControl.DestroyHandle(const AWinControl: TWinControl);
|
class procedure TQtWSWinControl.DestroyHandle(const AWinControl: TWinControl);
|
||||||
begin
|
begin
|
||||||
|
if not WSCheckHandleAllocated(AWinControl, 'DestroyHandle') then
|
||||||
|
Exit;
|
||||||
|
if QtWidgetSet.IsValidHandle(AWinControl.Handle) then
|
||||||
TQtWidget(AWinControl.Handle).Release;
|
TQtWidget(AWinControl.Handle).Release;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -626,7 +626,9 @@ begin
|
|||||||
APopupParent := TCustomForm(AWinControl).GetRealPopupParent;
|
APopupParent := TCustomForm(AWinControl).GetRealPopupParent;
|
||||||
if (APopupParent <> nil) then
|
if (APopupParent <> nil) then
|
||||||
begin
|
begin
|
||||||
Widget.setParent(TQtWidget(APopupParent.Handle).Widget);
|
//attach destroy event to PopupParent.Handle.Widget via signal on Widget
|
||||||
|
//use setRealPopupParent, issue #41433
|
||||||
|
Widget.setRealPopupParent(TQtWidget(APopupParent.Handle).Widget);
|
||||||
Widget.setWindowFlags(Widget.windowFlags or QtDialog); // issue #41241
|
Widget.setWindowFlags(Widget.windowFlags or QtDialog); // issue #41241
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -641,6 +643,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
Widget.setVisible(AWinControl.HandleObjectShouldBeVisible);
|
Widget.setVisible(AWinControl.HandleObjectShouldBeVisible);
|
||||||
|
if not AWinControl.HandleObjectShouldBeVisible then
|
||||||
|
begin
|
||||||
|
// issue #41433
|
||||||
|
if Widget.PopupParent <> nil then
|
||||||
|
Widget.setRealPopupParent(nil);
|
||||||
|
end;
|
||||||
Widget.EndUpdate;
|
Widget.EndUpdate;
|
||||||
|
|
||||||
{$IFDEF HASX11}
|
{$IFDEF HASX11}
|
||||||
|
Loading…
Reference in New Issue
Block a user