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
|
||||
Tab: TQueryTab;
|
||||
Section: String;
|
||||
Sections: TStringList;
|
||||
TabsIni: TIniFile;
|
||||
SectionTabExists: Boolean;
|
||||
begin
|
||||
// Store query tab unsaved contents and setup, in tabs.ini
|
||||
|
||||
try
|
||||
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
|
||||
Tab.BackupUnsavedContent;
|
||||
Section := Tab.Uid;
|
||||
@ -2190,6 +2189,24 @@ begin
|
||||
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
|
||||
TabsIni.Free;
|
||||
except
|
||||
|
Reference in New Issue
Block a user