mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
Issue #140: Erase ini section of a closed tab, in which the user loaded some physical file. Fixes wrongly restored tabs which were closed in previous session.
This commit is contained in:
@ -2165,16 +2165,15 @@ procedure TMainForm.StoreTabs;
|
|||||||
var
|
var
|
||||||
Tab: TQueryTab;
|
Tab: TQueryTab;
|
||||||
Section: String;
|
Section: String;
|
||||||
|
Sections: TStringList;
|
||||||
TabsIni: TIniFile;
|
TabsIni: TIniFile;
|
||||||
|
SectionTabExists: Boolean;
|
||||||
begin
|
begin
|
||||||
// Store query tab unsaved contents and setup, in tabs.ini
|
// Store query tab unsaved contents and setup, in tabs.ini
|
||||||
|
|
||||||
try
|
try
|
||||||
TabsIni := InitTabsIniFile;
|
TabsIni := InitTabsIniFile;
|
||||||
|
|
||||||
// Todo: erase sections from closed tabs
|
|
||||||
// ab: is that really required? Tabs with deleted files don't get restored anyway.
|
|
||||||
|
|
||||||
for Tab in QueryTabs do begin
|
for Tab in QueryTabs do begin
|
||||||
Tab.BackupUnsavedContent;
|
Tab.BackupUnsavedContent;
|
||||||
Section := Tab.Uid;
|
Section := Tab.Uid;
|
||||||
@ -2190,6 +2189,24 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// Tabs with deleted files don't get restored anyway. But closed tabs with physically existing
|
||||||
|
// files still need to be erased
|
||||||
|
Sections := TStringList.Create;
|
||||||
|
TabsIni.ReadSections(Sections);
|
||||||
|
for Section in Sections do begin
|
||||||
|
SectionTabExists := False;
|
||||||
|
for Tab in QueryTabs do begin
|
||||||
|
if Tab.Uid = Section then begin
|
||||||
|
SectionTabExists := True;
|
||||||
|
Break;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
// Delete tab section if no tab was closed
|
||||||
|
if not SectionTabExists then begin
|
||||||
|
TabsIni.EraseSection(Section);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
// Close file
|
// Close file
|
||||||
TabsIni.Free;
|
TabsIni.Free;
|
||||||
except
|
except
|
||||||
|
Reference in New Issue
Block a user