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
Contributor
rob_bb10
Posts: 26
Registered: ‎06-09-2013
My Device: N serial
My Carrier: NIM
Accepted Solution

crush in bb::cascades::ImageView::setImage

no idea about this...:smileysad:

 

crush info:

Process 190877883 (mapview) terminated SIGSEGV code=1 fltno=11 ip=797774ec(/base/usr/lib/libbbcascades.so.1@_ZN2bb8cascades9ImageView16resetImageSourceEv+0x137) mapaddr=001774ec. ref=00000010 bdslot=1

 

 

qml:

            ImageView
            {
                id: myImageView
                objectName: "imageObj"
                visible: false
                //scalingMethod: ScalingMethod.AspectFit
                preferredHeight: 768
                preferredWidth: 768
            }

 

Button {

...

onClicked:
{

      mapViewTest.startGenMapImage();
}

}

 

code:

void MapViewDemo::startGenMapImage()
{

    ......

    bb::smileytongue:latform::geo::GeoList gList = mapView->mapData()->defaultProvider()->toGeoList();
    bb::cascades::maps::MapImageGenerator* pMapImgGen = new MapImageGenerator(viewpro, gList);

    connect(pMapImgGen, SIGNAL(finished(bb::cascades::maps::MapImageGenerator*)),
            this, SLOT(imageIsReady(bb::cascades::maps::MapImageGenerator*)));

    pMapImgGen_->start();

}

 

 

void MapViewDemo::imageIsReady(bb::cascades::maps::MapImageGenerator* pMapImgGen)
{
    if (!pMapImgGen->error())
    {
        bb::cascades::Image img(pMapImgGen->imageData());
        imgView_->setImage(img);   //crushed
        imgView_->setVisible(true);
    }
    else
    {
        qDebug() << "App::generate image error:" << pMapImgGen->error();
    }
    delete pMapImgGen;

}

 

 

 

Please use plain text.
Developer
simon_hain
Posts: 16,113
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: crush in bb::cascades::ImageView::setImage

one of the variables you are accessing is null, probably imgView_
----------------------------------------------------------
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
Please use plain text.
Contributor
rob_bb10
Posts: 26
Registered: ‎06-09-2013
My Device: N serial
My Carrier: NIM

Re: crush in bb::cascades::ImageView::setImage

Tried ,still crush.

If I write a single qml page to display the image, it's no problem.

 

but if I did as below, it was crush everytime.

 

main.qml:

            ,ActionItem {
                title: qsTr("Display Image")
                ActionBar.placement: ActionBarPlacement.InOverflow
                onTriggered: {
                    //_mapViewTest.addPinAtCurrentMapCenter();
                    navigationPane.push(mapimageview.createObject())
                }
            }

 

mapimageview.qml

Page {

    Container
    {
        topMargin: 20

            ImageView
            {
                id: myImageView
                objectName: "imageviewObj"
                visible: false
                //scalingMethod: ScalingMethod.AspectFit
                preferredHeight: 768
                preferredWidth: 768
            }

 

after mapImageGenerater's signal finished emitting, below function is triggered.

void MapViewDemo::imageIsReady(bb::cascades::maps::MapImageGenerator* pMapImgGen)
{
    if (!pMapImgGen->error())
    {
        bb::cascades::Image img(pMapImgGen->imageData());
        if (imgView_)
        {
            imgView_->setImage(img);  //still crush here
            imgView_->setVisible(true);
        }
    }
    else
    {
        qDebug() << "App::generate image error:" << pMapImgGen->error();
    }
    delete pMapImgGen;

Please use plain text.
Developer
simon_hain
Posts: 16,113
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: crush in bb::cascades::ImageView::setImage

check 'img', and check if imgView_ is a valid pointer.
----------------------------------------------------------
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
Please use plain text.
Contributor
rob_bb10
Posts: 26
Registered: ‎06-09-2013
My Device: N serial
My Carrier: NIM

Re: crush in bb::cascades::ImageView::setImage

[ Edited ]

I fix it. My bad.

The put the imageview into main.qml, then it's ok.

because the imageviewin the page which is destroyed after going back to main navigationpane.

The reference is out of the lifespan of mapview.

So I create the page and imageview by C++ code dynamically to control the page lifecycle.

otherway, I add a new tab to show imageview, it's more better.

 

Please use plain text.