1
0
mirror of synced 2024-09-18 18:06:09 +00:00

Fixed: double freeing of MonitorForm due to the introduction of the ObjectDictionary

Fixed: FS#2 - Automatically scroll event log
This commit is contained in:
Mark van Renswoude 2014-05-30 13:25:10 +00:00
parent acd998a845
commit 7186a68e1e
2 changed files with 14 additions and 12 deletions

View File

@ -46,7 +46,6 @@ object X2LogObserverMonitorForm: TX2LogObserverMonitorForm
List = True List = True
ShowCaptions = True ShowCaptions = True
TabOrder = 0 TabOrder = 0
ExplicitWidth = 350
object tbCopyDetails: TToolButton object tbCopyDetails: TToolButton
Left = 0 Left = 0
Top = 0 Top = 0
@ -69,7 +68,6 @@ object X2LogObserverMonitorForm: TX2LogObserverMonitorForm
BevelKind = bkFlat BevelKind = bkFlat
BevelOuter = bvNone BevelOuter = bvNone
TabOrder = 1 TabOrder = 1
ExplicitWidth = 350
object HeaderControl1: THeaderControl object HeaderControl1: THeaderControl
Left = 0 Left = 0
Top = 0 Top = 0
@ -83,7 +81,6 @@ object X2LogObserverMonitorForm: TX2LogObserverMonitorForm
Width = 378 Width = 378
end> end>
NoSizing = True NoSizing = True
ExplicitWidth = 346
end end
object reDetails: TRichEdit object reDetails: TRichEdit
Left = 0 Left = 0
@ -113,7 +110,6 @@ object X2LogObserverMonitorForm: TX2LogObserverMonitorForm
Align = alClient Align = alClient
BevelOuter = bvNone BevelOuter = bvNone
TabOrder = 1 TabOrder = 1
ExplicitWidth = 634
object vstLog: TVirtualStringTree object vstLog: TVirtualStringTree
Left = 0 Left = 0
Top = 22 Top = 22
@ -138,7 +134,6 @@ object X2LogObserverMonitorForm: TX2LogObserverMonitorForm
OnGetImageIndex = vstLogGetImageIndex OnGetImageIndex = vstLogGetImageIndex
OnGetHint = vstLogGetHint OnGetHint = vstLogGetHint
OnInitNode = vstLogInitNode OnInitNode = vstLogInitNode
ExplicitWidth = 634
Columns = < Columns = <
item item
Options = [coAllowClick, coDraggable, coEnabled, coParentBidiMode, coParentColor, coShowDropMark, coVisible, coAllowFocus] Options = [coAllowClick, coDraggable, coEnabled, coParentBidiMode, coParentColor, coShowDropMark, coVisible, coAllowFocus]
@ -168,7 +163,6 @@ object X2LogObserverMonitorForm: TX2LogObserverMonitorForm
List = True List = True
ShowCaptions = True ShowCaptions = True
TabOrder = 1 TabOrder = 1
ExplicitWidth = 634
object tbClear: TToolButton object tbClear: TToolButton
Left = 0 Left = 0
Top = 0 Top = 0
@ -200,7 +194,7 @@ object X2LogObserverMonitorForm: TX2LogObserverMonitorForm
Left = 448 Left = 448
Top = 48 Top = 48
Bitmap = { Bitmap = {
494C0101090040008C0010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600 494C010109004000940010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000400000003000000001002000000000000030 0000000000003600000028000000400000003000000001002000000000000030
0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000

View File

@ -142,10 +142,10 @@ const
{ TLogEntryNode } { TLogEntryNode }
procedure TLogEntryNodeData.Initialize(ALevel: TX2LogLevel; const AMessage: string; ADetails: IX2LogDetails); procedure TLogEntryNodeData.Initialize(ALevel: TX2LogLevel; const AMessage: string; ADetails: IX2LogDetails);
begin begin
Time := Now; Self.Time := Now;
Level := ALevel; Self.Level := ALevel;
Message := AMessage; Self.Message := AMessage;
Details := ADetails; Self.Details := ADetails;
end; end;
@ -208,7 +208,7 @@ begin
begin begin
if FInstances[log] = AForm then if FInstances[log] = AForm then
begin begin
FInstances.Remove(log); FInstances.ExtractPair(log);
break; break;
end; end;
end; end;
@ -306,13 +306,21 @@ begin
if Log is called from the main thread, or queue it asynchronously } if Log is called from the main thread, or queue it asynchronously }
TThread.Queue(nil, TThread.Queue(nil,
procedure procedure
var
scroll: Boolean;
begin begin
if not Paused then if not Paused then
begin begin
scroll := (vstLog.RootNodeCount > 0) and (vstLog.BottomNode = vstLog.GetLast);
node := vstLog.AddChild(nil); node := vstLog.AddChild(nil);
nodeData := vstLog.GetNodeData(node); nodeData := vstLog.GetNodeData(node);
nodeData^.Initialize(ALevel, AMessage, ADetails); nodeData^.Initialize(ALevel, AMessage, ADetails);
if scroll then
vstLog.ScrollIntoView(node, False);
UpdateUI; UpdateUI;
end else end else
begin begin