mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-26 03:01:07 +08:00
Issue #140:
* 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:
@ -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;
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user