11-19-2012 05:35 AM
If you use the SystemDialog::show method to display the System dialog as a modeless dialog where/when do you actually 'delete' the created SystemDialog + thus free the memory it was using.
In the SystemDialog:::exec() case you can simply delete the dialog once the exec() returns. But clearly you cant do that with a modeless dialog.
As far as we can see its really unsafe to assume you can delete the dialog in the finished() signal, not least of which its almost certainly still executing code + thus probably manipulating object property.
Solved! Go to Solution.
11-19-2012 09:46 AM
11-19-2012 10:17 AM
Not sure we really understand your response.
A memory leak is a memory leak regardless of size. Eventually it will use ALL the memory on your device/allocated to your process + invariably cause problems. Granted it may take a while if its only a few bytes, but thats not really the point.
By definition when a modeless dialog is being displayed your app is also running. Clearly you cannot just simply delete resources used by the modeless dialog (or the dialog object itself) at any random point during the running of the app and still expect the dialog to be displayed correctly + deliver its finished signal.
Regardless of whether the implmentation of system dialogs is in a separate OS service/thread/process or whatever at a minimum you must be deleting any linkages back to your app if you delete the SystemDialog object created in your local heap space and to which you connected a method to its finished signal.
Generally deleting an object within one of its own methods (or callbacks) or in this case a 'signal/slot pairing' results in memory corruption UNLESS the object is very explictly coded to deal with 'self deletion' and any environment its running in can handle that object being removed while in the middle of some of its methods being accessed.
With respect, the docs are lacking in quite a few areas, plain wrong in others + simply non existant in quite a few areas. There is nothing in the docs that suggest you should ever delete a SystemDialog created e.g. using std code such as
SystemDialog* dlg = new SystemDialog("title");
but if you dont you have a memory leak - you can see it happening in the Malloc Info panes of the IDE.
So the question stands, where are you expected to delete the SystemDialog object thats created in your local heap space when its run as a modeless dialog
12-05-2012 02:32 PM
If relevant to people:
Now the documentation has been updated there is a method called 'deleteLater()' which apparently is safe to call when in the finished slot - presumably it runs some kind of deferred pseudo garbage collector...