Browse Source

GridUtils: refactor-out ExecuteUIThread workaround

Herman Schoenfeld 6 years ago
parent
commit
a009519d6e
1 changed files with 14 additions and 6 deletions
  1. 14 6
      src/gui-classic/UGridUtils.pas

+ 14 - 6
src/gui-classic/UGridUtils.pas

@@ -217,7 +217,9 @@ Type
     FBlockStart, FBlockEnd : Int64;
     FBlockStart, FBlockEnd : Int64;
     procedure DoUpdateBlockChainGrid(ANode : TNode; var AList : TList<TBlockChainData>; ABlockStart, ABlockEnd : Int64);
     procedure DoUpdateBlockChainGrid(ANode : TNode; var AList : TList<TBlockChainData>; ABlockStart, ABlockEnd : Int64);
   protected
   protected
+    FGridUpdateCount: Integer;
     procedure BCExecute; override;
     procedure BCExecute; override;
+    procedure RefreshGrid;
   public
   public
     constructor Create(ABlockChainGrid : TBlockChainGrid);
     constructor Create(ABlockChainGrid : TBlockChainGrid);
   End;
   End;
@@ -351,7 +353,6 @@ begin
   FisProcessing := True;
   FisProcessing := True;
   FProcessedList := TOrderedCardinalList.Create;
   FProcessedList := TOrderedCardinalList.Create;
   Suspended := False;
   Suspended := False;
-  ExecuteUIThread := True;
 end;
 end;
 
 
 destructor TAccountsGridUpdateThread.Destroy;
 destructor TAccountsGridUpdateThread.Destroy;
@@ -889,6 +890,7 @@ begin
       for i := 0 to list.Count-1 do begin
       for i := 0 to list.Count-1 do begin
         FOperationsGrid.FOperationsResume.Add(list[i]);
         FOperationsGrid.FOperationsResume.Add(list[i]);
       end;
       end;
+      Synchronize(FOperationsGrid.InitGrid);
       FOperationsGrid.InitGrid;
       FOperationsGrid.InitGrid;
     end;
     end;
   finally
   finally
@@ -902,7 +904,6 @@ begin
   inherited Create(True);
   inherited Create(True);
   FreeOnTerminate := False;
   FreeOnTerminate := False;
   Suspended := False;
   Suspended := False;
-  ExecuteUIThread := True;
 end;
 end;
 
 
 procedure TOperationsGridUpdateThread.DoUpdateOperationsGrid(ANode: TNode; var AList: TList<TOperationResume>);
 procedure TOperationsGridUpdateThread.DoUpdateOperationsGrid(ANode: TNode; var AList: TList<TOperationResume>);
@@ -1345,9 +1346,9 @@ begin
         FBlockChainGrid.FBlockChainDataList.Add(Llist[i]);
         FBlockChainGrid.FBlockChainDataList.Add(Llist[i]);
       end;
       end;
       if Assigned(FBlockChainGrid.DrawGrid) then begin
       if Assigned(FBlockChainGrid.DrawGrid) then begin
-        if Llist.Count>0 then FBlockChainGrid.DrawGrid.RowCount := Llist.Count+1
-         else FBlockChainGrid.DrawGrid.RowCount := 2;
-         FBlockChainGrid.FDrawGrid.Invalidate;
+        if Llist.Count>0 then FGridUpdateCount := Llist.Count+1
+        else FGridUpdateCount := 2;
+        Synchronize(RefreshGrid);
       end;
       end;
     end;
     end;
   finally
   finally
@@ -1355,13 +1356,20 @@ begin
   end;
   end;
 end;
 end;
 
 
+procedure TBlockChainGridUpdateThread.RefreshGrid;
+begin
+  if not Assigned(FBlockChainGrid) or not Assigned(FBlockChainGrid.DrawGrid)
+    then Exit;
+  FBlockChainGrid.DrawGrid.RowCount := FGridUpdateCount;
+  FBlockChainGrid.FDrawGrid.Invalidate;
+end;
+
 constructor TBlockChainGridUpdateThread.Create(ABlockChainGrid : TBlockChainGrid);
 constructor TBlockChainGridUpdateThread.Create(ABlockChainGrid : TBlockChainGrid);
 begin
 begin
   FBlockChainGrid := ABlockChainGrid;
   FBlockChainGrid := ABlockChainGrid;
   inherited Create(True);
   inherited Create(True);
   FreeOnTerminate := False;
   FreeOnTerminate := False;
   Suspended := False;
   Suspended := False;
-  ExecuteUIThread := True;
 end;
 end;
 
 
 procedure TBlockChainGridUpdateThread.DoUpdateBlockChainGrid(ANode: TNode; var AList: TList<TBlockChainData>; ABlockStart, ABlockEnd : Int64);
 procedure TBlockChainGridUpdateThread.DoUpdateBlockChainGrid(ANode: TNode; var AList: TList<TBlockChainData>; ABlockStart, ABlockEnd : Int64);