25 |
|
* |
26 |
|
*) |
27 |
|
unit FBActivityMonitor; |
28 |
+ |
{$IFDEF MSWINDOWS} |
29 |
+ |
{$DEFINE WINDOWS} |
30 |
+ |
{$ENDIF} |
31 |
|
|
32 |
|
{$IFDEF FPC} |
33 |
< |
{$mode objfpc}{$H+} |
33 |
> |
{$mode delphi} |
34 |
|
{$interfaces COM} |
35 |
|
{$ENDIF} |
36 |
|
|
50 |
|
|
51 |
|
{$IFDEF DEBUGINTERFACES} |
52 |
|
TMonitoredObject = class(TInterfacedObject) |
50 |
– |
private |
51 |
– |
FObjectCount: integer; static; |
53 |
|
public |
54 |
|
constructor Create; |
55 |
|
destructor Destroy; override; |
153 |
|
{ TMonitoredObject } |
154 |
|
|
155 |
|
{$IFDEF DEBUGINTERFACES} |
156 |
+ |
var |
157 |
+ |
FObjectCount: integer; |
158 |
+ |
|
159 |
|
constructor TMonitoredObject.Create; |
160 |
|
begin |
161 |
|
inherited Create; |
340 |
|
var i: integer; |
341 |
|
begin |
342 |
|
for i := 0 to Length(FInterfaces) - 1 do |
343 |
+ |
begin |
344 |
+ |
{$IFNDEF FPC} |
345 |
+ |
{With Delphi we need to explicitly null the object reference when it is |
346 |
+ |
going to be disposed of. This is because Delphi does not drop the reference |
347 |
+ |
count until after the containing object is released.} |
348 |
+ |
if (FInterfaces[i] <> nil) and (FInterfaces[i].RefCount <= 2) then |
349 |
+ |
FInterfaces[i] := nil; |
350 |
+ |
{$ENDIF} |
351 |
|
FInterfaceRefs[i] := nil; |
352 |
+ |
end; |
353 |
|
end; |
354 |
|
|
355 |
|
end. |