Skip to content

Commit 0563b4d

Browse files
committed
fix: flashing main form in background after cancel session manager
Decided to fully show the main form before showing the session manager through an Application.OnIdle event. Hoping no user manages to click somewhere on the main form, causing crashes. The only reasonable alternative was to show the session manager before TMainForm is created, but this would be more effort.
1 parent cf9ed85 commit 0563b4d

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

source/main.pas

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,6 +1408,7 @@ TMainForm = class(TExtForm)
14081408
SysLanguage: String;
14091409
MainFormCreated: Boolean = False;
14101410
MainFormAfterCreateDone: Boolean = False;
1411+
SessionManagerStartupDone: Boolean = False;
14111412
PostponedLogItems: TDBLogItems;
14121413

14131414
const
@@ -2167,9 +2168,7 @@ procedure TMainForm.AfterFormCreate;
21672168
StatsCall: THttpDownload;
21682169
StatsURL: String;
21692170
SessionPaths: TStringlist;
2170-
DlgResult: TModalResult;
21712171
Tab: TQueryTab;
2172-
SessionManager: TConnForm;
21732172
begin
21742173
// Check for connection parameters on commandline or show connections form.
21752174
if AppSettings.ReadBool(asUpdatecheck) then begin
@@ -2281,25 +2280,6 @@ procedure TMainForm.AfterFormCreate;
22812280
end;
22822281
end;
22832282

2284-
// Display session manager
2285-
if Connections.Count = 0 then begin
2286-
// Cannot be done in OnCreate because we need ready forms here:
2287-
SessionManager := TConnForm.Create(Self);
2288-
DlgResult := mrCancel;
2289-
try
2290-
DlgResult := SessionManager.ShowModal;
2291-
SessionManager.Free;
2292-
except
2293-
// Work around VCL bug: Suppress access violation in TCustomForm.IsFormSizeStored
2294-
// when closing dialog via Alt+F4
2295-
end;
2296-
if DlgResult = mrCancel then begin
2297-
//Free;
2298-
//Exit;
2299-
actExitApplicationExecute(nil);
2300-
end;
2301-
end;
2302-
23032283
// Restore backup'ed query tabs
23042284
if AppSettings.RestoreTabsInitValue then begin
23052285
TimerStoreTabs.Enabled := RestoreTabs;
@@ -14608,7 +14588,23 @@ procedure TMainForm.RefreshHelperNode(NodeIndex: Cardinal);
1460814588

1460914589

1461014590
procedure TMainForm.ApplicationIdle(Sender: TObject; var Done: Boolean);
14591+
var
14592+
DlgResult: TModalResult;
14593+
SessionManager: TConnForm;
1461114594
begin
14595+
// Display session manager
14596+
// Cannot be done in OnCreate because we need ready forms here
14597+
if (not SessionManagerStartupDone) and (Connections.Count = 0) then begin
14598+
SessionManagerStartupDone := True;
14599+
SessionManager := TConnForm.Create(Self);
14600+
DlgResult := SessionManager.ShowModal;
14601+
SessionManager.Free;
14602+
if DlgResult = mrCancel then begin
14603+
actExitApplicationExecute(nil);
14604+
end;
14605+
end;
14606+
SessionManagerStartupDone := True;
14607+
1461214608
if AppSettings.PortableMode
1461314609
and (not AppSettings.PortableModeReadOnly)
1461414610
and (FLastPortableSettingsSave < GetTickCount-60000) then begin

0 commit comments

Comments
 (0)