Jump to content

[SOLVED] Interpreter hiccup


photo

Recommended Posts

Posted

Good morning,

 

I got a very strange behavior with the attached sample:

 

We have two different classes:

 

- "RootContainer" (Sub: ContainerGroup)

- "RootWidget" (Sub: Label)

 

Both of them inherit the function "getParent".

 

In setElementAndValidate(...) we pass an created class and calling: "_parent.getParent()"

 

If the passed object is an instance of "RootContainer" we can call getParent(), if object is an instance of "RootWidget" the interpreter has some troubles: 

 
typeof(_parent): GUI::QB::ContainerRoot
Name: containergroup
typeof(_parent): GUI::QB::ContainerGroup
Name: label
Machine::do_callucfv(): "GUI::QB::Label 0x7f1e82d83800 (196613:0:0)" is not a suitable user class
Stack dump:
0x0000: GUI::QB::Label 0x7f1e82d83800 (196613:0:0)
Call stack:
00: 0x00000618 setElementAndValidate()
01: 0x0000066d init()
Disassemble:
0x0000063f: callucfv   ContainerRoot.getParent 0x00000571
0x00000643: popucx     ContainerRoot
0x00000645: popv       parent
 
 
If we change the parameter type from "ContainerGroup _parent" to "void", "Widget" or "int" the interpreter is crashing now at "RootContainer" as well.

If we check the class type with "typeof" and cast  _parent to the specific class, its working.
For me it seems like a bug in the interpreter that causes a wrong detection of the instance type.
 
The expected behavior should be that the instance is correctly detected and code execution continues.

Greetings

 

sample.tar.gz

Posted

Hello, Lars

We can't cast _parent without specific class declaration.
"void", "Widget" or "int" types don't have getParent() method.

And when you call getParent() you need explicit declaration of it's type:

parent = GUI::QB::Label(_parent).getParent();
parent = GUI::QB::ContainerRoot(_parent).getParent();
...

Or you can use is_base_class


You can also use proposed tip from Tips and tricks : "Interface class support and virtual function declaration"

Posted

Hello Necris,

 

i'm gonna check it with the Tip and tricks section :)

 

Thanks so far!

Posted

Update:
With multiple inheritance this problem was solved.

Thanks for this tip :)
Greetings

Lars
 

×
×
  • Create New...