From: Julian Smart Date: Tue, 20 Aug 2002 08:34:05 +0000 (+0000) Subject: Applied patch [ 597320 ] Return wxNotebook::SetSelection value X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/90b18154c8a72d3f522d3960a70517d40bbf02e0 Applied patch [ 597320 ] Return wxNotebook::SetSelection value By Hans Van Leemputten (hansvl) According to the documentation wxNotebook::SetSelection() should return the previous selection... (Like wxMSW does) but the wxUniv version returns the currently selected selection. Patch was tested with wxX11. Applied patch [ 597313 ] Popup menu still used after deletion By Hans Van Leemputten (hansvl) - This patch exists out of 2 parts; Part 1 is a patch to show the problem with the menu sample (this part is just to show the problem and should not be put into CVS!). Part 2 is the fix and should be put in CVS. (src/univ/menu.cpp) - Instructions to reproduce the problem with the menu sample: 1. Apply part 1 of the patch only. 2. Run the sample after recompiling it. 3. Press "Close Test" -> "Close", this will basically remove the current menu bar and recreate it again and re-use the menu item "Close test" from the old menu bar... 4. Again press "Close Test", doing this will already crash the sample. - The cause of the problem is that the m_popupMenu in wxMenu is deleted because it is a child of the old menu bar (Note: it does not get destroyed by the wxMenu destructor, but by DestroyChildren()) and m_popupMenu is not put back to NULL when this happens... - This patch was tested only with wxX11. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16609 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/univ/menu.cpp b/src/univ/menu.cpp index 1a70ef1eb4..62dc90a1c8 100644 --- a/src/univ/menu.cpp +++ b/src/univ/menu.cpp @@ -314,6 +314,12 @@ wxPopupMenuWindow::wxPopupMenuWindow(wxWindow *parent, wxMenu *menu) wxPopupMenuWindow::~wxPopupMenuWindow() { + // When m_popupMenu in wxMenu is deleted because it + // is a child of an old menu bar being deleted (note: it does + // not get destroyed by the wxMenu destructor, but + // by DestroyChildren()), m_popupMenu should be reset to NULL. + + m_menu->m_popupMenu = NULL; } // ---------------------------------------------------------------------------- diff --git a/src/univ/notebook.cpp b/src/univ/notebook.cpp index 39bf56b228..4c19121069 100644 --- a/src/univ/notebook.cpp +++ b/src/univ/notebook.cpp @@ -255,7 +255,7 @@ int wxNotebook::SetSelection(int nPage) m_pages[m_sel]->Show(); } - return m_sel; + return selOld; } void wxNotebook::ChangePage(int nPage)