Skip to content
Permalink
Browse files

Issue #140: Erase ini section of a closed tab, in which the user load…

…ed some physical file. Fixes wrongly restored tabs which were closed in previous session.
  • Loading branch information...
ansgarbecker committed Jun 3, 2019
1 parent 6e2bca2 commit 19775ef9410c8a66fa7ebf95e168df777812c9bc
Showing with 20 additions and 3 deletions.
  1. +20 −3 source/main.pas
@@ -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 @@ procedure TMainForm.StoreTabs;
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

0 comments on commit 19775ef

Please sign in to comment.
You can’t perform that action at this time.