Browse Source

Update UFRMRandomOperations.pas

Fixed bug: Added show logs in main thread
PascalCoin 6 years ago
parent
commit
3553f126f6
1 changed files with 13 additions and 5 deletions
  1. 13 5
      src/gui-classic/UFRMRandomOperations.pas

+ 13 - 5
src/gui-classic/UFRMRandomOperations.pas

@@ -29,7 +29,7 @@ uses
   {$ENDIF}
   {$ENDIF}
   Classes, SysUtils,  Forms, Controls, Graphics, Dialogs, StdCtrls,
   Classes, SysUtils,  Forms, Controls, Graphics, Dialogs, StdCtrls,
   ExtCtrls, Menus, ActnList, UAccounts, UBlockChain, UNode, UCrypto, UBaseTypes,
   ExtCtrls, Menus, ActnList, UAccounts, UBlockChain, UNode, UCrypto, UBaseTypes,
-  UWallet, UConst, UTxMultiOperation, UOpTransaction, UThread;
+  UWallet, UConst, UTxMultiOperation, UOpTransaction, UThread, ULog;
 
 
 type
 type
 
 
@@ -86,6 +86,7 @@ type
     FBankNotify : TPCBankNotify;
     FBankNotify : TPCBankNotify;
     FCurrOperationsComp : TPCOperationsComp;
     FCurrOperationsComp : TPCOperationsComp;
     FRandomGeneratorThread : TRandomGeneratorThread;
     FRandomGeneratorThread : TRandomGeneratorThread;
+    FInternalLog : TLog;
     procedure SetSourceNode(AValue: TNode);
     procedure SetSourceNode(AValue: TNode);
     procedure SetSourceWalletKeys(AValue: TWalletKeysExt);
     procedure SetSourceWalletKeys(AValue: TWalletKeysExt);
     procedure NewLog(logTxt : String);
     procedure NewLog(logTxt : String);
@@ -93,6 +94,7 @@ type
     procedure UpdateRandomGeneratorThread(DestroyOnly : Boolean);
     procedure UpdateRandomGeneratorThread(DestroyOnly : Boolean);
     procedure OnRandomGeneratoThreadUpdated(Sender : TObject);
     procedure OnRandomGeneratoThreadUpdated(Sender : TObject);
     function IsProcessingRandomOperations : Boolean;
     function IsProcessingRandomOperations : Boolean;
+    procedure OnInternalLog(logtype : TLogType; Time : TDateTime; ThreadID : TThreadID; Const sender, logtext : String);
   public
   public
     Property SourceNode : TNode read FSourceNode write SetSourceNode;
     Property SourceNode : TNode read FSourceNode write SetSourceNode;
     Property SourceWalletKeys : TWalletKeysExt read FSourceWalletKeys write SetSourceWalletKeys;
     Property SourceWalletKeys : TWalletKeysExt read FSourceWalletKeys write SetSourceWalletKeys;
@@ -117,8 +119,6 @@ implementation
   {$R *.lfm}
   {$R *.lfm}
 {$ENDIF}
 {$ENDIF}
 
 
-Uses ULog;
-
 { TRandomGeneratorThread }
 { TRandomGeneratorThread }
 
 
 procedure TRandomGeneratorThread.OnBankNewBlock(Sender: TObject);
 procedure TRandomGeneratorThread.OnBankNewBlock(Sender: TObject);
@@ -429,6 +429,9 @@ begin
   FBankNotify.OnNewBlock:=OnBankNewBlock;
   FBankNotify.OnNewBlock:=OnBankNewBlock;
   FCurrOperationsComp := TPCOperationsComp.Create(Nil);
   FCurrOperationsComp := TPCOperationsComp.Create(Nil);
   FRandomGeneratorThread := Nil;
   FRandomGeneratorThread := Nil;
+  FInternalLog := TLog.Create(Self);
+  FInternalLog.ProcessGlobalLogs := False;
+  FInternalLog.OnNewLog := OnInternalLog;
   mLogs.Clear;
   mLogs.Clear;
 end;
 end;
 
 
@@ -489,8 +492,7 @@ end;
 procedure TFRMRandomOperations.NewLog(logTxt: String);
 procedure TFRMRandomOperations.NewLog(logTxt: String);
 begin
 begin
   if length(logTxt)>300 then logTxt := Copy(logTxt,1,300)+'...';
   if length(logTxt)>300 then logTxt := Copy(logTxt,1,300)+'...';
-  
-  mLogs.Lines.Add(Format('%s %s',[FormatDateTime('hh:nn:ss.zzz',Now),logTxt]));
+  FInternalLog.NotifyNewLog(ltdebug,'',logTxt);
 end;
 end;
 
 
 procedure TFRMRandomOperations.OnBankNewBlock(Sender: TObject);
 procedure TFRMRandomOperations.OnBankNewBlock(Sender: TObject);
@@ -499,6 +501,12 @@ begin
   FCurrOperationsComp.SanitizeOperations;
   FCurrOperationsComp.SanitizeOperations;
 end;
 end;
 
 
+procedure TFRMRandomOperations.OnInternalLog(logtype: TLogType; Time: TDateTime;
+  ThreadID: TThreadID; const sender, logtext: String);
+begin
+  mLogs.Lines.Add(Format('%s %s',[FormatDateTime('hh:nn:ss.zzz',Now),logtext]));
+end;
+
 procedure TFRMRandomOperations.UpdateRandomGeneratorThread(DestroyOnly : Boolean);
 procedure TFRMRandomOperations.UpdateRandomGeneratorThread(DestroyOnly : Boolean);
 begin
 begin
   if Assigned(FRandomGeneratorThread) then begin
   if Assigned(FRandomGeneratorThread) then begin