Deleting a button at runtime - why do I need SetTmpDefaultItem
?
Vadim Zeitlin
vadim at wxwidgets.org
Tue Feb 5 16:37:20 PST 2008
On Tue, 5 Feb 2008 16:41:11 +0100 Thibault Genessay <tibogens at gmail.com> wrote:
TG> In ~wxButton(), it effectively tries to unset itself as its parent top
TG> window's default item, but fails to do so
TG> (in wxButton::UnsetTmpDefault()) because the
TG> GetTLWParentIfNotBeingDeleted() returns NULL. Actually, given the
TG> description of this method, this behavior seems okay, because the
TG> window is being deleted.
The name is not very clear, it should only return NULL if TLW parent is
being deleted, not wxButton itself.
TG> What seems to trick the button is that its parent (the subpanel) is
TG> being deleted, while the TLW that contains it is not, so the search
This patch should help then, could you please test it?
Index: src/msw/button.cpp
===================================================================
--- src/msw/button.cpp (revision 51537)
+++ src/msw/button.cpp (working copy)
@@ -376,11 +376,12 @@
{
for ( ; win; win = win->GetParent() )
{
- if ( win->IsBeingDeleted() )
- return NULL;
-
if ( win->IsTopLevel() )
+ {
+ if ( win->IsBeingDeleted() )
+ return NULL;
break;
+ }
}
wxASSERT_MSG( win, _T("button without top level parent?") );
Thanks!
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
More information about the wx-users
mailing list