diff --git a/source/apphelpers.pas b/source/apphelpers.pas index 88185299..7c4da523 100644 --- a/source/apphelpers.pas +++ b/source/apphelpers.pas @@ -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; diff --git a/source/main.pas b/source/main.pas index f4341588..36b00351 100644 --- a/source/main.pas +++ b/source/main.pas @@ -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;