-
Notifications
You must be signed in to change notification settings - Fork 28
Memory management
dimitar-asenov edited this page May 11, 2012
·
1 revision
Here are some rules and tips regarding memory management in Envision, C++ and Qt:
- Have a clear (ideally documented) ownership model, that defines responsibility for objects. It must be clear:
- who owns an object?
- when is an object deleted?
- who and how deletes an object?
- Always delete objects derived from
Item
(QGraphicsItem
) manually. Qt's documentation says this is more efficient compared to letting their parents delete them automatically in their destructor. - Do not delete an
Item
in its own handler. Postpone the deletion until after the handler has finished executing. - An
Item
should not contain other items directly, but only through pointers.