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
Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

deleted dynamic qml elements receiving signals

We have encountered an issue with our dynamic qml components not getting deleted properly.

 

A Page is created dynamically, and populated by a number of Container objects that are created with createObject(this), setting the page as parent.

When the page is popped we call page.destroy() in onPopTransitionEnded, this should also delete all Container objects.

 

The container connect to a signal from a c++ component. It seems that this signal is not disconnected and the qml object somehow lingers in memory. The slot is called, but all of the properties are null, as if the Container is in some kind of limbo.

 

I have found a similar issue on StackOverflow:

http://stackoverflow.com/questions/8849031/dead-qml-elements-receiving-signals

However, i cannot find the onDestruction handler.

 

Any ideas how to disconnect the signals manually (or automatically)?

 

 

----------------------------------------------------------
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
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: deleted dynamic qml elements receiving signals

We've identified a similar (or identical) thing in pure QML.

For now, just ahead of my destroy() call, I've been doing this, with an appropriate routine provided in the Page (since I'm doing this only with Pages):

    onPopTransitionEnded: {
        try { page.disconnect_signals(); }
        catch (error) {}

        page.destroy();
    }

 

Crude, but so far it's been effective.  The disconnect_signals() routine simply mirrors any of my manual signalName.connect(someFunction) calls (usually done in onCreationCompleted) by doing signalName.disconnect(someFunction).


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: deleted dynamic qml elements receiving signals

[ Edited ]

that would be a bit bothersome, as we only delete the top object and rely on the tree for all the childen to be deleted :smileysad:

 

there is no slot that functions like onDestroyed?

----------------------------------------------------------
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
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: deleted dynamic qml elements receiving signals

i created a jira entry for it:
https://www.blackberry.com/jira/browse/BBTEN-856

I assume that it is a Qt issue, but maybe BlackBerry can fix it anyhow.
----------------------------------------------------------
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