Marmalade IwUIController causes crash when accessing IwUIElement objects

96 views Asked by At

I created an app that works which is similar to the examples from the Marmalade SDK. Then I tried to move the IwUIController derived class in a separate files .h/.cpp to clean the code up a bit but I get a crash every time I try to access any IwUIElement? For example:

CIwUIImage* image = IwSafeCast<CIwUIImage*>(pScreen->GetChildNamed("Image"));

pScreen is declared as

static CIwUIElement *pScreen;

and then in main(): pScreen = CIwUIElement::CreateFromResource("Screen");

What can be the reason for these crashes? Does the Controller class need to be in the same file as main()? I've tried to debug and the pointer appears to be passed properly.

1

There are 1 answers

0
johnfo On

Not sure it really counts as an answer, but I don't have enough stackoverflow reputation to comment apparently;-)

If you've got C++ code that worked OK until you split it into two files, I would seriously check the #include and other declarations are the same in the new two files as they were in the originals. 9 times out of 10, my experience is that for some reason something is not the same. Actually one specific issue worth checking for is that a struct or class is only partly declared (e.g. a forward declaration) in one file and has lost its parent.

Having said that, as Creator, said what were the symptoms of the crash? Is this possibly the dynamic cast failing of IwSafeCast failing?