Browse Source

* Fix bug ID #32889, handle ReadInterfaceRaw in TReader

git-svn-id: trunk@37856 -
michael 7 years ago
parent
commit
e160d4c530
2 changed files with 15 additions and 1 deletions
  1. 13 1
      rtl/objpas/classes/reader.inc
  2. 2 0
      rtl/objpas/rtlconst.inc

+ 13 - 1
rtl/objpas/classes/reader.inc

@@ -715,6 +715,8 @@ Var
   C : TComponent;
   P : integer;
   L : TLinkedList;
+  RI: Pointer; // raw interface
+  IIDStr: ShortString;
   
 begin
   If Assigned(FFixups) then
@@ -731,6 +733,16 @@ begin
       If Assigned(C) then
         if R.FPropInfo^.PropType^.Kind = tkInterface then
           SetInterfaceProp(R.FInstance,R.FPropInfo,C)
+        else if R.FPropInfo^.PropType^.Kind = tkInterfaceRaw then
+        begin
+          IIDStr := GetTypeData(R.FPropInfo^.PropType)^.IIDStr;
+          if IIDStr = '' then
+            raise EReadError.CreateFmt(SInterfaceNoIIDStr, [R.FPropInfo^.PropType^.Name]);
+          if C.GetInterface(IIDStr, RI) then
+            SetRawInterfaceProp(R.FInstance,R.FPropInfo,RI)
+          else
+            raise EReadError.CreateFmt(SComponentDoesntImplement, [C.ClassName, IIDStr]);
+        end
         else
           SetObjectProp(R.FInstance,R.FPropInfo,C)
       else
@@ -1397,7 +1409,7 @@ begin
       begin
         SetVariantProp(Instance,PropInfo,ReadVariant);
       end;
-    tkClass, tkInterface:
+    tkClass, tkInterface, tkInterfaceRaw:
       case FDriver.NextValue of
         vaNil:
           begin

+ 2 - 0
rtl/objpas/rtlconst.inc

@@ -70,6 +70,7 @@ ResourceString
   SCmplxUnexpectedEOS           = 'Unexpected end of string [%s]';
   SColorPrefix                  = 'Color';
   SColorTags                    = 'ABCDEFGHIJKLMNOP';
+  SComponentDoesntImplement     = 'Component "%s" does not implement "%s"';
   SComponentNameTooLong         = 'Component name "%s" exceeds 64 character limit';
   SConfirmCreateDir             = 'The selected directory does not exist. Should it be created?';
   SControlParentSetToSelf       = 'A component can not have itself as parent';
@@ -142,6 +143,7 @@ ResourceString
   SParamIsNil                   = 'Parameter %s cannot be nil';
   SIniFileWriteError            = 'Unable to write to "%s"';
   SInsertLineError              = 'Line could not be inserted';
+  SInterfaceNoIIDStr            = 'Interface "%s" does not have an IIDStr';
   SInvalidActionCreation        = 'Invalid action creation';
   SInvalidActionEnumeration     = 'Invalid action enumeration';
   SInvalidActionRegistration    = 'Invalid action registration';