瀏覽代碼

FIX: Don't change page index in DestroyAllPages

Alexander Koblov 4 年之前
父節點
當前提交
d82eed4555
共有 1 個文件被更改,包括 11 次插入1 次删除
  1. 11 1
      src/ufileviewnotebook.pas

+ 11 - 1
src/ufileviewnotebook.pas

@@ -3,7 +3,7 @@
    -------------------------------------------------------------------------
    This unit contains TFileViewPage and TFileViewNotebook objects.
 
-   Copyright (C) 2016-2019 Alexander Koblov ([email protected])
+   Copyright (C) 2016-2021 Alexander Koblov ([email protected])
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -105,6 +105,7 @@ type
 
   TFileViewNotebook = class(TPageControl)
   private
+    FCanChangePageIndex: Boolean;
     FNotebookSide: TFilePanelSelect;
     FStartDrag: Boolean;
     FDraggedPageIndex: Integer;
@@ -137,6 +138,7 @@ type
     procedure WndProc(var Message: TLMessage); override;
 {$ENDIF}
     function AddPage: TFileViewPage;
+    function CanChangePageIndex: Boolean; override;
     function InsertPage(Index: Integer): TFileViewPage; reintroduce;
     function NewEmptyPage: TFileViewPage;
     function NewPage(CloneFromPage: TFileViewPage): TFileViewPage;
@@ -403,6 +405,7 @@ begin
   ShowHint := True;
 
   FHintPageIndex := -1;
+  FCanChangePageIndex := True;
   FNotebookSide := NotebookSide;
   FStartDrag := False;
 
@@ -453,6 +456,11 @@ begin
   Result := InsertPage(PageCount);
 end;
 
+function TFileViewNotebook.CanChangePageIndex: Boolean;
+begin
+  Result:= (inherited CanChangePageIndex) and FCanChangePageIndex;
+end;
+
 function TFileViewNotebook.InsertPage(Index: Integer): TFileViewPage;
 begin
   Tabs.Insert(Index, '');
@@ -535,11 +543,13 @@ procedure TFileViewNotebook.DestroyAllPages;
 var
    tPage:TFileViewPage;
 begin
+  FCanChangePageIndex:= False;
   while PageCount > 0 do
   begin
     tPage:=Page[0];
     if tPage<>nil then FreeAndNil(tPage);
   end;
+  FCanChangePageIndex:= True;
 end;
 
 procedure TFileViewNotebook.ActivatePrevTab;