Deleting a button at runtime - why do I need SetTmpDefaultItem ?
Thibault Genessay
tibogens at gmail.com
Tue Feb 5 07:41:11 PST 2008
On Feb 5, 2008 4:26 PM, Vadim Zeitlin <vadim at wxwidgets.org> wrote:
> On Tue, 5 Feb 2008 16:21:42 +0100 Thibault Genessay <tibogens at gmail.com> wrote:
>
> TG> I have a form (in a dialog) that contains subpanels that can be added
> TG> / removed dynamically by the user. Basically, it looks like
> TG> Thunderbird's "Edit->Find->Search Messages ..." dialog. When you click
> TG> '+' it adds a panel with choices, edit fields and '+' and '-' buttons.
> TG> When a '+' button, a new panel is created - this works perfectly.
> TG> But when the '-' button is clicked, it detaches the panel from its
> TG> sizer and Destroy()s it. Everything is OK up to the point where I
> TG> click another button on the dialog - the program crashes.
> ...
> TG> Is this a bug ?
>
> Yes. But I don't know why does it happen, the button is supposed to unset
> itself as (temporary) default button when it's being destroyed. Can you
> please try to debug what happens in ~wxButton of your button? If you can't
> find it, please try reproducing the bug with the minimal amount of the code
> possible and open a bug report about it on SF.
>
In ~wxButton(), it effectively tries to unset itself as its parent top
window's default item, but fails to do so
(in wxButton::UnsetTmpDefault()) because the
GetTLWParentIfNotBeingDeleted() returns NULL. Actually, given the
description of this method, this behavior seems okay, because the
window is being deleted.
What seems to trick the button is that its parent (the subpanel) *is*
being deleted, while the TLW that contains it is not, so the search
for the TLW aborts before it reaches the dialog.
Why in the first place was it a problem to change the TLW's default
and tmp default items when the button's parent is being deleted ?
Thank you
> Thanks,
> VZ
>
> --
> TT-Solutions: wxWidgets consultancy and technical support
> http://www.tt-solutions.com/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
>
>
More information about the wx-users
mailing list