[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re[2]: Determine whether window created yet [Was: [lmi] wx segfault iter
From: |
Vadim Zeitlin |
Subject: |
Re[2]: Determine whether window created yet [Was: [lmi] wx segfault iterating on GetChildren()] |
Date: |
Wed, 15 Mar 2006 20:04:23 +0100 |
On Wed, 15 Mar 2006 17:23:41 +0000 Greg Chicares <address@hidden> wrote:
GC> On 2006-3-11 15:06 UTC, Vadim Zeitlin wrote:
GC> > On Sat, 11 Mar 2006 14:36:07 +0000 Greg Chicares <address@hidden> wrote:
GC> >
GC> > GC> It's somewhat distasteful to use IsShown() to determine whether
GC> > GC> a window has been "fully created". After all, a notebook that was
GC> > GC> once shown may be temporarily hidden. But is there any better way?
GC> >
GC> > No, not out of the box. But you can assume that the window is fully
GC> > created as soon as you get almost any message for it so it's common to set
GC> > a m_isCreated flag in EVT_WINDOW_CREATE or even EVT_SIZE or EVT_IDLE
GC> > handlers.
GC>
GC> Okay. I want to add a variable to a wxDialog-derived class:
GC>
GC> /// is_fully_created_: True iff dialog construction has completed and
GC> /// destruction has not yet begun.
This will work but, again, I think it's a bit sloppy to rely on such
generic flag. Usually you shouldn't need it and if/when you do there are
more often than not better things to test for. In particular in your case I
still think that a dynamic Connect() would be a better solution.
GC> When should I change its value back to false, so that I can use this
GC> flag to prevent a dialog that's in the process of destruction from
GC> trying to do something it shouldn't?
GC> - a wxWindow::Destroy() virtual override?
GC> - an EVT_CLOSE handler?
GC> - my class's destructor?
Probably the last one but, again, it really depends on what do you
want/need it for exactly and so I'm afraid there is no generic "best"
solution.
Regards,
VZ
Determine whether window created yet [Was: [lmi] wx segfault iterating on GetChildren()], Greg Chicares, 2006/03/11