From d16ba4644a175411cf43ac5a5fab60e70d2260b8 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 28 Mar 2010 22:39:32 +0000 Subject: [PATCH] Clarify wxMenu objects allocation rules. Make it clear that only the menu directly passed to wxWindow::PopupMenu() doesn't need to be allocated on the heap and that its submenus still do. Closes #11851. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63771 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- interface/wx/menu.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/interface/wx/menu.h b/interface/wx/menu.h index ad1044dc67..98f2eb56eb 100644 --- a/interface/wx/menu.h +++ b/interface/wx/menu.h @@ -416,9 +416,13 @@ public: @section menu_allocation Allocation strategy - All menus except the popup ones must be created on the @b heap. - All menus attached to a menubar or to another menu will be deleted by their - parent when it is deleted. + All menus must be created on the @b heap because all menus attached to a + menubar or to another menu will be deleted by their parent when it is + deleted. The only exception to this rule are the popup menus (i.e. menus + used with wxWindow::PopupMenu()) as wxWidgets does not destroy them to + allow reusing the same menu more than once. But the exception applies only + to the menus themselves and not to any submenus of popup menus which are + still destroyed by wxWidgets as usual and so must be heap-allocated. As the frame menubar is deleted by the frame itself, it means that normally all menus used are deleted automatically.