Browse Source

* Fix bug ID #32168

git-svn-id: trunk@36757 -
michael 8 years ago
parent
commit
9878dc280b
2 changed files with 5 additions and 1 deletions
  1. 4 1
      rtl/inc/objpas.inc
  2. 1 0
      rtl/inc/objpash.inc

+ 4 - 1
rtl/inc/objpas.inc

@@ -1044,7 +1044,10 @@
       begin
          _Release:=interlockeddecrement(frefcount);
          if _Release=0 then
-           self.destroy;
+           begin
+           if interlockedincrement(fdestroycount)=1 then
+             self.destroy;
+           end;
       end;
 
     procedure TInterfacedObject.AfterConstruction;

+ 1 - 0
rtl/inc/objpash.inc

@@ -297,6 +297,7 @@
        TInterfacedObject = class(TObject,IUnknown)
        protected
           frefcount : longint;
+          FDestroyCount : longint;
           { implement methods of IUnknown }
           function QueryInterface({$IFDEF FPC_HAS_CONSTREF}constref{$ELSE}const{$ENDIF} iid : tguid;out obj) : longint;{$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
           function _AddRef : longint;{$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};