From a86831340fc8da4caf49052f1e9f3ec2f973ca23 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Thu, 10 Mar 2005 15:46:31 +0000 Subject: [PATCH] make sure we don't have two associations pointing to the same control git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32712 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/window.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index ae454e6a56..003444f185 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -659,7 +659,9 @@ void wxAssociateControlWithMacControl(ControlRef inControl, wxWindow *control) void wxRemoveMacControlAssociation(wxWindow *control) { - wxWinMacControlList.DeleteObject(control); + // remove all associations pointing to us + while ( wxWinMacControlList.DeleteObject(control) ) + {} } #else @@ -686,13 +688,22 @@ void wxAssociateControlWithMacControl(ControlRef inControl, wxWindow *control) void wxRemoveMacControlAssociation(wxWindow *control) { // iterate over all the elements in the class - MacControlMap::iterator it; - for ( it = wxWinMacControlList.begin(); it != wxWinMacControlList.end(); ++it ) + // is the iterator stable ? as we might have two associations pointing to the same wxWindow + // we should go on... + + bool found = true ; + while( found ) { - if ( it->second == control ) + found = false ; + MacControlMap::iterator it; + for ( it = wxWinMacControlList.begin(); it != wxWinMacControlList.end(); ++it ) { - wxWinMacControlList.erase(it); - break; + if ( it->second == control ) + { + wxWinMacControlList.erase(it); + found = true ; + break; + } } } } -- 2.45.2