Fixed: memory leak when using MonitorForm
Changed: TX2LogBaseClient is now reference-counted
This commit is contained in:
parent
6d5355e0b6
commit
acd998a845
@ -25,6 +25,8 @@ var
|
||||
MainForm: TMainForm;
|
||||
|
||||
begin
|
||||
ReportMemoryLeaksOnShutdown := True;
|
||||
|
||||
Application.Initialize;
|
||||
Application.MainFormOnTaskbar := True;
|
||||
Application.Title := 'X²LogTest';
|
||||
|
@ -30,10 +30,8 @@ object MainForm: TMainForm
|
||||
Align = alClient
|
||||
Images = ilsObservers
|
||||
TabOrder = 0
|
||||
ExplicitHeight = 305
|
||||
object tsEvent: TTabSheet
|
||||
Caption = 'Event Observer '
|
||||
ExplicitHeight = 277
|
||||
object mmoEvent: TMemo
|
||||
AlignWithMargins = True
|
||||
Left = 8
|
||||
@ -48,7 +46,6 @@ object MainForm: TMainForm
|
||||
ReadOnly = True
|
||||
ScrollBars = ssVertical
|
||||
TabOrder = 0
|
||||
ExplicitHeight = 229
|
||||
end
|
||||
object btnEventStart: TButton
|
||||
Left = 8
|
||||
@ -71,7 +68,6 @@ object MainForm: TMainForm
|
||||
end
|
||||
object tsFile: TTabSheet
|
||||
Caption = 'File Observer'
|
||||
ExplicitHeight = 277
|
||||
object lblFilename: TLabel
|
||||
Left = 12
|
||||
Top = 64
|
||||
@ -134,7 +130,6 @@ object MainForm: TMainForm
|
||||
end
|
||||
object tsNamedPipe: TTabSheet
|
||||
Caption = 'Named Pipe Observer'
|
||||
ExplicitHeight = 277
|
||||
object lblPipeName: TLabel
|
||||
Left = 12
|
||||
Top = 64
|
||||
@ -183,7 +178,6 @@ object MainForm: TMainForm
|
||||
Align = alBottom
|
||||
BevelOuter = bvNone
|
||||
TabOrder = 1
|
||||
ExplicitTop = 482
|
||||
object btnClose: TButton
|
||||
Left = 520
|
||||
Top = 0
|
||||
@ -318,7 +312,7 @@ object MainForm: TMainForm
|
||||
Left = 552
|
||||
Top = 176
|
||||
Bitmap = {
|
||||
494C01010200140028000C000C00FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
|
||||
494C0101020014002C000C000C00FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
|
||||
0000000000003600000028000000300000000C00000001002000000000000009
|
||||
0000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000000000000000000000000000
|
||||
|
@ -107,6 +107,8 @@ begin
|
||||
SetLogResourceString(@LogMonitorFormButtonSaveDetails, 'Opslaan');
|
||||
SetLogResourceString(@LogMonitorFormStatusPaused, 'Gepauseerd: %d melding(en) overgeslagen');
|
||||
|
||||
SetLogResourceString(@LogMonitorFormSaveDetailsFilter, 'Alle bestanden (*.*)|*.*');
|
||||
|
||||
FLog := TX2Log.Create;
|
||||
FLog.SetExceptionStrategy(TX2LogmadExceptExceptionStrategy.Create);
|
||||
|
||||
|
@ -9,7 +9,7 @@ uses
|
||||
|
||||
|
||||
type
|
||||
TX2LogBaseClient = class(TInterfacedPersistent, IX2LogBase, IX2LogObservable)
|
||||
TX2LogBaseClient = class(TInterfacedObject, IX2LogBase, IX2LogObservable)
|
||||
private
|
||||
FObservers: TList<IX2LogObserver>;
|
||||
protected
|
||||
|
@ -11,7 +11,7 @@ uses
|
||||
type
|
||||
TX2GlobalLog = class(TObject)
|
||||
private class var
|
||||
FInstance: TX2Log;
|
||||
FInstance: IX2Log;
|
||||
protected
|
||||
class procedure CleanupInstance;
|
||||
public
|
||||
@ -59,8 +59,7 @@ end;
|
||||
|
||||
class procedure TX2GlobalLog.CleanupInstance;
|
||||
begin
|
||||
if Assigned(FInstance) then
|
||||
FreeAndNil(FInstance);
|
||||
FInstance := nil;
|
||||
end;
|
||||
|
||||
|
||||
|
@ -102,8 +102,6 @@ object X2LogObserverMonitorForm: TX2LogObserverMonitorForm
|
||||
ReadOnly = True
|
||||
ScrollBars = ssBoth
|
||||
TabOrder = 1
|
||||
ExplicitLeft = -2
|
||||
ExplicitWidth = 348
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -154,7 +152,7 @@ object X2LogObserverMonitorForm: TX2LogObserverMonitorForm
|
||||
end
|
||||
item
|
||||
Position = 2
|
||||
Width = 424
|
||||
Width = 428
|
||||
WideText = 'Message'
|
||||
end>
|
||||
end
|
||||
@ -202,7 +200,7 @@ object X2LogObserverMonitorForm: TX2LogObserverMonitorForm
|
||||
Left = 448
|
||||
Top = 48
|
||||
Bitmap = {
|
||||
494C010109004000880010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
|
||||
494C0101090040008C0010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
|
||||
0000000000003600000028000000400000003000000001002000000000000030
|
||||
0000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000000000000000000000000000
|
||||
|
@ -60,7 +60,7 @@ type
|
||||
procedure actSaveDetailsExecute(Sender: TObject);
|
||||
procedure actPauseExecute(Sender: TObject);
|
||||
private class var
|
||||
FInstances: TDictionary<IX2Log,TX2LogObserverMonitorForm>;
|
||||
FInstances: TObjectDictionary<IX2Log,TX2LogObserverMonitorForm>;
|
||||
private
|
||||
FFreeOnClose: Boolean;
|
||||
FLogToAttach: IX2Log;
|
||||
@ -160,7 +160,7 @@ begin
|
||||
log := (ALog as IX2Log);
|
||||
|
||||
if not Assigned(FInstances) then
|
||||
FInstances := TDictionary<IX2Log,TX2LogObserverMonitorForm>.Create;
|
||||
FInstances := TObjectDictionary<IX2Log,TX2LogObserverMonitorForm>.Create([doOwnsValues]);
|
||||
|
||||
if not FInstances.TryGetValue(log, Result) then
|
||||
begin
|
||||
@ -619,4 +619,9 @@ begin
|
||||
UpdateStatus;
|
||||
end;
|
||||
|
||||
|
||||
initialization
|
||||
finalization
|
||||
TX2LogObserverMonitorForm.CleanupInstances;
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user