View Issue Details

IDProjectCategoryView StatusLast Update
0032889FPCPatchpublic2017-12-29 11:54
ReporterAndrewHAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.1.1Product Build37818 
Target Version3.2.0Fixed in Version3.1.1 
Summary0032889: [PATCH] TReader does not handle tkInterfaceRaw
DescriptionTReader doesn't handle tkInterfaceRaw entries and gives the error unknown property type "22"

The attached patch fixed this for me.
TagsNo tags attached.
Fixed in Revision37856
FPCOldBugId0
FPCTarget
Attached Files
  • raw_interface.patch (2,544 bytes)
    diff --git a/rtl/objpas/classes/reader.inc b/rtl/objpas/classes/reader.inc
    index 60fec9244b..1dd916231b 100644
    --- a/rtl/objpas/classes/reader.inc
    +++ b/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
    diff --git a/rtl/objpas/rtlconst.inc b/rtl/objpas/rtlconst.inc
    index 30c09f694c..9132b16550 100644
    --- a/rtl/objpas/rtlconst.inc
    +++ b/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';
    
    raw_interface.patch (2,544 bytes)

Activities

AndrewH

2017-12-27 18:33

developer  

raw_interface.patch (2,544 bytes)
diff --git a/rtl/objpas/classes/reader.inc b/rtl/objpas/classes/reader.inc
index 60fec9244b..1dd916231b 100644
--- a/rtl/objpas/classes/reader.inc
+++ b/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
diff --git a/rtl/objpas/rtlconst.inc b/rtl/objpas/rtlconst.inc
index 30c09f694c..9132b16550 100644
--- a/rtl/objpas/rtlconst.inc
+++ b/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';
raw_interface.patch (2,544 bytes)

Michael Van Canneyt

2017-12-29 11:54

administrator   ~0105099

Applied the patch, thank you very much!

Issue History

Date Modified Username Field Change
2017-12-27 18:33 AndrewH New Issue
2017-12-27 18:33 AndrewH File Added: raw_interface.patch
2017-12-29 11:40 Michael Van Canneyt Assigned To => Michael Van Canneyt
2017-12-29 11:40 Michael Van Canneyt Status new => assigned
2017-12-29 11:54 Michael Van Canneyt Fixed in Revision => 37856
2017-12-29 11:54 Michael Van Canneyt Note Added: 0105099
2017-12-29 11:54 Michael Van Canneyt Status assigned => resolved
2017-12-29 11:54 Michael Van Canneyt Fixed in Version => 3.1.1
2017-12-29 11:54 Michael Van Canneyt Resolution open => fixed
2017-12-29 11:54 Michael Van Canneyt Target Version => 3.2.0