Skip to content

Commit

Permalink
Issue #140: remove a tab section from tabs.ini within RestoreTabs(), …
Browse files Browse the repository at this point in the history
…if its file does not exist
  • Loading branch information
ansgarbecker committed Apr 10, 2019
1 parent 430ea3b commit f4c1503
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions source/main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2203,16 +2203,26 @@ procedure TMainForm.RestoreTabs;
Filename := TabsIni.ReadString(Section, 'Filename', '');
BackupFilename := TabsIni.ReadString(Section, 'BackupFilename', '');
if not BackupFilename.IsEmpty then begin
Tab := ActiveOrEmptyQueryTab(False);
Tab.Uid := Section;
Tab.LoadContents(BackupFilename, True, TEncoding.UTF8);
Tab.MemoFilename := Filename;
Tab.Memo.Modified := True;
if FileExists(BackupFilename) then begin
Tab := ActiveOrEmptyQueryTab(False);
Tab.Uid := Section;
Tab.LoadContents(BackupFilename, True, TEncoding.UTF8);
Tab.MemoFilename := Filename;
Tab.Memo.Modified := True;
end else begin
// Remove ini item if file is gone
TabsIni.EraseSection(Section);
end;
end else if not Filename.IsEmpty then begin
Tab := ActiveOrEmptyQueryTab(False);
Tab.Uid := Section;
Tab.LoadContents(Filename, True, nil);
Tab.MemoFilename := Filename;
if FileExists(Filename) then begin
Tab := ActiveOrEmptyQueryTab(False);
Tab.Uid := Section;
Tab.LoadContents(Filename, True, nil);
Tab.MemoFilename := Filename;
end else begin
// Remove ini item if file is gone
TabsIni.EraseSection(Section);
end;
end;
end;
Sections.Free;
Expand Down

0 comments on commit f4c1503

Please sign in to comment.