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
Posts: 21
Registered: ‎04-12-2013
My Device: BlackBerry Z10
My Carrier: Rogers

Responsible resource cleanup in C++ Cascades app

Hi there,

 

Just wondering what the best practices are for cleaning up allocated resources in C++ cascades apps. Currently I've got some objects that are children of Cascades objects, and when I try to delete allocated objects in their destructors, I get a lovely SIGSEGV when I close my app. 

 

If I don't clean these up, I get a bunch of spam about not unrealizing my resources.

 

Are there any guides the community would recommend?

 

Thanks,
Richard

Developer
Posts: 188
Registered: ‎07-19-2012
My Device: Z10 LE
My Carrier: Three

Re: Responsible resource cleanup in C++ Cascades app

Any objects that use the Qt framework (including any Cascades items) are automatically deallocated once the that class's destructor is called. Keep in mind however that you should always set a parent for any cascades or Qt components you create in C++, as any orphaned classes will not be automatically swept up. Alternatively, you can explicitly deallocate a cascades object by using the deleteLater() method.

 

This does not apply to any classes which do not use the Q_OBJECT macro, you'll need to explicitly delete these. See the Object Ownership in QML & C++ sections of this document.



Did this post help you? If so, please make sure to "like" it!