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
Highlighted
Contributor
Posts: 13
Registered: ‎11-30-2012
My Device: Alpha
My Carrier: Pepephone

GroupDataModel c++ upgrading terminates app

Hello. I whant to upgrade the rows of a ListView, but app terminates. I have made this simple test

 

C++

BugTest::BugTest(bb::cascades::Application *app)
: QObject(app)
{
    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);

    // create root object for the UI
    AbstractPane *root = qml->createRootObject<AbstractPane>();
     GroupDataModel *model = new GroupDataModel(QStringList() << "country" << "continent");
    QVariantMap map;
    map["country"] = "Italy"; map["continent"] = "Europe"; model->insert(map);
    map["country"] = "Japan"; map["continent"] = "Asia"; model->insert(map);

    ListView *listView =root->findChild<ListView*>("list");
        if (listView){
            listView->setDataModel(model);
   }
    qml->setContextProperty("Main", this);
    app->setScene(root);
}
void BugTest::changePage(){
	QmlDocument *qml2 = QmlDocument::create("asset:///main.qml");
	AbstractPane *root2 = qml2->createRootObject<AbstractPane>();
    GroupDataModel *model = new GroupDataModel(QStringList() << "country" << "continent");
    QVariantMap map;
    map["country"] = "US"; map["continent"] = "America"; model->insert(map);
    map["country"] = "Mexico"; map["continent"] = "America"; model->insert(map);

    ListView *listView =root2->findChild<ListView*>("list");
        if (listView){
            listView->setDataModel(model);
   }
    qml2->setContextProperty("Main", this);
    Application::instance()->setScene(root2);

}

 qml:

 

import bb.cascades 1.0

Page {
    Container {
        Button {
            text: "Update list - Bug"
            objectName: "button2"
            onClicked: Main.changePage();
            
        }
        ListView {
            objectName: "list"
            id: lista
        }
    }
}

 

After the changePage method has finish, app terminates with message: 

Process 89993425 (bugTest) terminated SIGSEGV code=1 fltno=11 ip=7821bac0(/base/usr/lib/qt4/lib/libQtDeclarative.so.4.8.3@_ZNK22QDeclarativeExpression11scopeObjectEv+0x7) mapaddr=0011bac0. ref=00000028

 

Is this a bug?

Is there a way to get the current scene for getting the actual listView without reloading the full page?

 

regards