From: Vadim Zeitlin Date: Wed, 19 Jan 2011 10:46:31 +0000 (+0000) Subject: Mention modal dialogs in the wxWindow objects allocation guide. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/6e91eb1f761a1d9bfb0cccc2141fd61a8b978a36 Mention modal dialogs in the wxWindow objects allocation guide. The modal dialogs are an important exception to the usual rules of dealing with wxWindow-derived objects so mention them here too. Closes #12880. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66709 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/docs/doxygen/mainpages/devtips.h b/docs/doxygen/mainpages/devtips.h index 49f62b7700..e85350cc5c 100644 --- a/docs/doxygen/mainpages/devtips.h +++ b/docs/doxygen/mainpages/devtips.h @@ -199,8 +199,15 @@ the wxWidgets delayed deletion can take effect. This waits until idle time (when all messages have been processed) to actually delete the window, to avoid problems associated with the GUI sending events to deleted windows. -Don't create a window on the stack, because this will interfere with delayed -deletion. +In general wxWindow-derived objects should always be allocated on the heap +as wxWidgets will destroy them itself. The only, but important, exception to +this rule are the modal dialogs, i.e. wxDialog objects which are shown using +wxDialog::ShowModal() method. They may be allocated on the stack and, indeed, +usually are local variables to ensure that they are destroyed on scope exit as +wxWidgets does not destroy them unlike with all the other windows. So while it +is still possible to allocate modal dialogs on the heap, you should still +destroy or delete them explicitly in this case instead of relying on wxWidgets +doing it. If you decide to allocate a C++ array of objects (such as wxBitmap) that may be cleaned up by wxWidgets, make sure you delete the array explicitly before