Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Developer
Posts: 12
Registered: ‎11-01-2012
My Device: simulator
My Carrier: simulator
Accepted Solution

Launching a new QML page from c++ causes crash

The following code always crashes without any useful messages being emitted. I have checked all the variables and none are null. I can step through the c++ code and it doesn't crash at that point. The application hangs and after a while gdb just crashes.

 

No source available for "_start_() at 0x1a8ea60"

 

My QML:

 

import bb.cascades 1.0


Page {
    Container {
        layout: StackLayout {
        }
        Label {
            text: "Hello"
        }
    }
}

 

My c++:

 

void GConnectBB::startMenu() {
    QmlDocument *qml2 = QmlDocument::create("asset:///MainMenu.qml");
    if (!qml2->hasErrors()) {

        AbstractPane *page2 = qml2->createRootObject<AbstractPane>();
        if (page2) {
            this->myApp->setScene(page2);
        }
    }
}

 

How can I debug this problem??

Developer
Posts: 16,997
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Launching a new QML page from c++ causes crash

I am not sure if you are supposed to set a new scene like that, but i am sure Peter will answer that in the canadian morning Smiley Happy

The solution I have chosen is:
- Emit a signal in a c++ class that is registered with qml
- connect the signal in qml, using classname.signalname.connect(functionName)
- in the function just call navigationPane.push

Or you can use a Sheet object, which can display itself using open()
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
New Developer
Posts: 12
Registered: ‎11-01-2012
My Device: simulator
My Carrier: simulator

Re: Launching a new QML page from c++ causes crash

I am actually calling the startMenu() function from Qml. NavigationPane.push is not right for me because it is a login screen. I don't want people being able to go back or peek to the login screen. I also want that section of my application be a TabbedPane, whereas login and friends are in a NavigationPane. 

 

I got that code snippet from here: https://developer.blackberry.com/cascades/reference/bb__cascades__qmldocument.html

 

 

Developer
Posts: 16,997
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Launching a new QML page from c++ causes crash

If you use a Sheet, you can set peekEnabled to false.
https://developer.blackberry.com/cascades/reference/bb__cascades__sheet.html#peekenabled
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 526
Registered: ‎05-17-2009
My Device: 9900
My Carrier: ATT

Re: Launching a new QML page from c++ causes crash

Pretty sure you need to access the app object in a static way. You shouldnt need to keep a pointer to it.

Application::instance()->setScene(page2);
Like all of my posts
New Developer
Posts: 12
Registered: ‎11-01-2012
My Device: simulator
My Carrier: simulator

Re: Launching a new QML page from c++ causes crash

Thanks for this. I will keep it in mind. It wasn't immediately obvious so I stored a pointer to it. I'm not sure this will cause the problem however unless the pointer is null, which it is not.