GTK2: Fix firing TCommonDialog.OnShow twice. Part of Issue #0021163.

git-svn-id: trunk@52814 -
This commit is contained in:
bart 2016-08-17 11:21:22 +00:00
parent dc5c4b535c
commit df62e1d21c

View File

@ -626,7 +626,12 @@ begin
or GDK_KEY_RELEASE_MASK or GDK_KEY_PRESS_MASK); or GDK_KEY_RELEASE_MASK or GDK_KEY_PRESS_MASK);
LCLComponent:=GetLCLObject(Widget); LCLComponent:=GetLCLObject(Widget);
if LCLComponent is TCommonDialog then if LCLComponent is TCommonDialog then
begin
{$ifdef DebugCommonDialogEvents}
debugln(['GTKDialogRealizeCB calling DoShow']);
{$endif}
TCommonDialog(LCLComponent).DoShow; TCommonDialog(LCLComponent).DoShow;
end;
Result:=true; Result:=true;
end; end;
@ -636,6 +641,8 @@ end;
Result: GBoolean Result: GBoolean
This function is called, before a commondialog is destroyed This function is called, before a commondialog is destroyed
(Only when the user aborts the dialog, not if the dialog closes as the result
of a click on one of itś buttons)
-------------------------------------------------------------------------------} -------------------------------------------------------------------------------}
function gtkDialogCloseQueryCB(widget: PGtkWidget; data: gPointer): GBoolean; function gtkDialogCloseQueryCB(widget: PGtkWidget; data: gPointer): GBoolean;
cdecl; cdecl;
@ -643,20 +650,30 @@ var
theDialog : TCommonDialog; theDialog : TCommonDialog;
CanClose: boolean; CanClose: boolean;
begin begin
{$ifdef DebugCommonDialogEvents}
debugln(['>>>>gtkDialogCloseQueryCB A']);
{$endif}
Result := False; // true = do nothing, false = destroy or hide window Result := False; // true = do nothing, false = destroy or hide window
if (Data=nil) then ; if (Data=nil) then ;
// data is not the commondialog. Get it manually. // data is not the commondialog. Get it manually.
theDialog := TCommonDialog(GetLCLObject(Widget)); theDialog := TCommonDialog(GetLCLObject(Widget));
if theDialog=nil then exit; if theDialog=nil then exit;
if theDialog.OnCanClose<>nil then begin if theDialog.OnCanClose<>nil then begin
theDialog.UserChoice := mrCancel;
CanClose:=True; CanClose:=True;
theDialog.OnCanClose(theDialog,CanClose); {$ifdef DebugCommonDialogEvents}
debugln(['gtkDialogCloseQueryCB calling DoCanClose']);
{$endif}
theDialog.DoCanClose(CanClose);
Result:=not CanClose; Result:=not CanClose;
end; end;
if not Result then begin if not Result then begin
StoreCommonDialogSetup(theDialog); StoreCommonDialogSetup(theDialog);
DestroyCommonDialogAddOns(theDialog); DestroyCommonDialogAddOns(theDialog);
end; end;
{$ifdef DebugCommonDialogEvents}
debugln(['gtkDialogCloseQueryCB End']);
{$endif}
end; end;
{------------------------------------------------------------------------------- {-------------------------------------------------------------------------------
@ -668,10 +685,16 @@ end;
-------------------------------------------------------------------------------} -------------------------------------------------------------------------------}
function gtkDialogDestroyCB(widget: PGtkWidget; data: gPointer): GBoolean; cdecl; function gtkDialogDestroyCB(widget: PGtkWidget; data: gPointer): GBoolean; cdecl;
begin begin
{$ifdef DebugCommonDialogEvents}
debugln(['gtkDialogDestroyCB A']);
{$endif}
Result := True; Result := True;
if (Widget=nil) then ; if (Widget=nil) then ;
TCommonDialog(data).UserChoice := mrAbort; TCommonDialog(data).UserChoice := mrCancel;
TCommonDialog(data).Close; TCommonDialog(data).Close;
{$ifdef DebugCommonDialogEvents}
debugln(['gtkDialogDestroyCB End']);
{$endif}
end; end;
{------------------------------------------------------------------------------- {-------------------------------------------------------------------------------
@ -685,7 +708,6 @@ end;
function GTKDialogKeyUpDownCB(Widget: PGtkWidget; Event : pgdkeventkey; function GTKDialogKeyUpDownCB(Widget: PGtkWidget; Event : pgdkeventkey;
Data: gPointer) : GBoolean; cdecl; Data: gPointer) : GBoolean; cdecl;
begin begin
//debugln('GTKDialogKeyUpDownCB A ');
Result:=CallBackDefaultReturn; Result:=CallBackDefaultReturn;
if (Widget=nil) then ; if (Widget=nil) then ;