Browse Source

* getinterface fixed

florian 20 years ago
parent
commit
3a6006367f
1 changed files with 28 additions and 17 deletions
  1. 28 17
      rtl/inc/objpas.inc

+ 28 - 17
rtl/inc/objpas.inc

@@ -614,14 +614,18 @@
           IEntry: pinterfaceentry;
           IEntry: pinterfaceentry;
         begin
         begin
           IEntry:=getinterfaceentry(iid);
           IEntry:=getinterfaceentry(iid);
-          if Assigned(IEntry) then begin
-            PPointer(@obj)^:=Pointer(Self)+IEntry^.IOffset;
-            getinterface:=True;
-          end
-          else begin
-            PPointer(@Obj)^:=nil;
-            getinterface:=False;
-          end;
+          if Assigned(IEntry) then
+            begin
+              Pointer(obj):=Pointer(Self)+IEntry^.IOffset;
+              if assigned(pointer(obj)) then
+                iinterface(obj)._AddRef;
+              getinterface:=True;
+            end
+          else
+            begin
+              PPointer(@Obj)^:=nil;
+              getinterface:=False;
+            end;
         end;
         end;
 
 
       function TObject.getinterfacebystr(const iidstr : string;out obj) : boolean;
       function TObject.getinterfacebystr(const iidstr : string;out obj) : boolean;
@@ -629,14 +633,18 @@
           IEntry: pinterfaceentry;
           IEntry: pinterfaceentry;
         begin
         begin
           IEntry:=getinterfaceentrybystr(iidstr);
           IEntry:=getinterfaceentrybystr(iidstr);
-          if Assigned(IEntry) then begin
-            PPointer(@obj)^:=Pointer(Self)+IEntry^.IOffset;
-            getinterfacebystr:=True;
-          end
-          else begin
-            PPointer(@Obj)^:=nil;
-            getinterfacebystr:=False;
-          end;
+          if Assigned(IEntry) then
+            begin
+              Pointer(obj):=Pointer(Self)+IEntry^.IOffset;
+              if assigned(pointer(obj)) then
+                iinterface(obj)._AddRef;
+              getinterfacebystr:=True;
+            end
+          else
+            begin
+              PPointer(@Obj)^:=nil;
+              getinterfacebystr:=False;
+            end;
         end;
         end;
 
 
       class function TObject.getinterfaceentry(const iid : tguid) : pinterfaceentry;
       class function TObject.getinterfaceentry(const iid : tguid) : pinterfaceentry;
@@ -758,7 +766,10 @@
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.48  2005-04-05 21:05:31  peter
+  Revision 1.49  2005-04-28 17:58:18  florian
+    * getinterface fixed
+
+  Revision 1.48  2005/04/05 21:05:31  peter
     * call initspecialchars if one of the specialchars is configured
     * call initspecialchars if one of the specialchars is configured
       for the first time
       for the first time