* store tab setup when application exits, as the TimerStoreTabs interval may not yet be reached
* remember startup value of asRestoreTabs option, which may change while the application runs, which in turn may cause problems when RestoreTabs wasn't called
This commit is contained in:
Ansgar Becker
2019-04-13 09:32:58 +02:00
parent f5734fece1
commit e9cc528632
2 changed files with 15 additions and 3 deletions

View File

@ -200,6 +200,7 @@ type
FSessionPath: String;
FRegistry: TRegistry;
FPortableMode: Boolean;
FRestoreTabsInitValue: Boolean;
FSettingsFile: String;
FSettings: Array[TAppSettingIndex] of TAppSetting;
procedure InitSetting(Index: TAppSettingIndex; Name: String;
@ -250,6 +251,8 @@ type
function DirnameUserDocuments: String;
function DirnameSnippets: String;
function DirnameBackups: String;
// "Static" options, initialized in OnCreate only. For settings which need a restart to take effect.
property RestoreTabsInitValue: Boolean read FRestoreTabsInitValue;
end;
@ -3683,6 +3686,10 @@ begin
InitSetting(asPreferencesWindowWidth, 'PreferencesWindowWidth', 740);
InitSetting(asPreferencesWindowHeight, 'PreferencesWindowHeight', 500);
InitSetting(asFileDialogEncoding, 'FileDialogEncoding_%s', 0);
// Initialization values
FRestoreTabsInitValue := ReadBool(asRestoreTabs);
end;

View File

@ -1537,6 +1537,11 @@ begin
StoreLastSessions;
// Store tab setup for the last time, before tabs are destroyed
if TimerStoreTabs.Enabled then begin
TimerStoreTabs.OnTimer(Sender);
end;
// Some grid editors access the registry - be sure these are gone before freeing AppSettings
QueryTabs.Clear;
DataGrid.EndEditNode;
@ -2105,7 +2110,7 @@ begin
end;
// Restore backup'ed query tabs
if AppSettings.ReadBool(asRestoreTabs) then begin
if AppSettings.RestoreTabsInitValue then begin
RestoreTabs;
TimerStoreTabs.Enabled := True;
end;
@ -11165,7 +11170,7 @@ begin
msg := f_('Save changes to file %s ?', [Tab.MemoFilename])
else
msg := f_('Save content of tab "%s"?', [Trim(Tab.TabSheet.Caption)]);
if AppSettings.ReadBool(asRestoreTabs) and AppIsClosing then begin
if AppSettings.RestoreTabsInitValue and AppIsClosing then begin
msg := msg + CRLF + CRLF + _('Your code is saved anyway, as auto-restoring is activated.');
end;
@ -11193,7 +11198,7 @@ begin
end;
// Auto-backup logic
if AppSettings.ReadBool(asRestoreTabs) then begin
if AppSettings.RestoreTabsInitValue then begin
if AppIsClosing then begin
// Do last backup before app closes
Tab.BackupUnsavedContent;