Periodically store portable settings file, each 60 seconds. In case of a crash, the user does not loose dialog settings and whatever was customized. See http://www.heidisql.com/forum.php?t=18144#p18243

This commit is contained in:
Ansgar Becker
2015-04-26 13:31:08 +00:00
parent 1bc2c32be3
commit 7ab04b5254
3 changed files with 29 additions and 3 deletions

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: HeidiSQL\n"
"POT-Creation-Date: 2012-11-05 21:40\n"
"PO-Revision-Date: 2015-04-03 22:00+0100\n"
"PO-Revision-Date: 2015-04-26 15:27+0100\n"
"Last-Translator: Ansgar Becker <anse@heidisql.com>\n"
"Language-Team: English (http://www.transifex.com/projects/p/heidisql/"
"language/en/)\n"
@ -4347,6 +4347,10 @@ msgstr "Registry dump, deprecated"
msgid "Settings successfully restored from %s"
msgstr "Settings successfully restored from %s"
#. Automatic export of portable settings
msgid "Portable settings file written, with %d changes."
msgstr "Portable settings file written, with %d changes."
#: main.pas:2142
msgid "Splitting SQL queries ..."
msgstr "Splitting SQL queries ..."

View File

@ -226,8 +226,10 @@ type
procedure ResetPath;
property SessionPath: String read FSessionPath write SetSessionPath;
property PortableMode: Boolean read FPortableMode;
property Writes: Integer read FWrites;
procedure ImportSettings(Filename: String);
procedure ExportSettings(Filename: String);
procedure ExportSettings(Filename: String); overload;
procedure ExportSettings; overload;
end;
@ -3792,6 +3794,11 @@ begin
end;
procedure TAppSettings.ExportSettings;
begin
ExportSettings(FSettingsFile);
end;
end.

View File

@ -1023,6 +1023,8 @@ type
FCaptions: TStringList;
FLastCaptionChange: Cardinal;
FListTablesSorted: Boolean;
FLastPortableSettingsSave: Cardinal;
FLastAppSettingsWrites: Integer;
// Host subtabs backend structures
FHostListResults: TDBQueryList;
@ -1783,6 +1785,10 @@ begin
FJumpList := TJumpList.Create;
FJumpList.ApplicationId := APPNAME + IntToStr(GetExecutableBits);
end;
FLastCaptionChange := 0;
FLastPortableSettingsSave := 0;
FLastAppSettingsWrites := 0;
end;
@ -11615,15 +11621,24 @@ begin
btnDonate.Caption := FCaptions[i];
FLastCaptionChange := GetTickCount;
end;
if AppSettings.PortableMode and (FLastPortableSettingsSave < GetTickCount-60000) then begin
if AppSettings.Writes > FLastAppSettingsWrites then begin
AppSettings.ExportSettings;
LogSQL(f_('Portable settings file written, with %d changes.', [AppSettings.Writes-FLastAppSettingsWrites]), lcDebug);
end;
FLastAppSettingsWrites := AppSettings.Writes;
FLastPortableSettingsSave := GetTickCount;
end;
// Sort list tables in idle time, so ListTables.TreeOptions.AutoSort does not crash the list
// when dropping a right-clicked database
if (PageControlMain.ActivePage = tabDatabase) and (not FListTablesSorted) then begin
ListTables.SortTree(ListTables.Header.SortColumn, ListTables.Header.SortDirection);
FListTablesSorted := True;
end;
end;
procedure TMainForm.ApplicationDeActivate(Sender: TObject);
begin
// Prevent completion window from showing up after Alt-Tab. See issue #2640