Restarting application
Vadim Zeitlin
vadim at wxwindows.org
Wed May 2 19:03:46 PDT 2007
On 2 May 2007 15:23:37 -0700 chrismc911 at hotmail.com wrote:
> I have a situation where I need to restart my application when a major
> system change has been recognized to make sure the new configuration
> is used correctly in my app.
What you do doesn't seem at all like restarting the application. So if you
don't need to really restart it, maybe you should just avoid recreating the
main frame also?
> To do this, I have created a custom event and put a handler function
> into my wxApp. There I try something like this:
>
> - create a new wxFrame as placeholder and make it toplevel (such that
> the app does not exit when I delete the main toplevel window)
This can be achieved more easily by calling SetExitOnFrameDelete(false).
> - call Destory on the main window
> - create the main windows again using 'new' and set it as toplevel
> - delete the placeholder window
>
> Unfortunately I get weird memory exceptions and the likes.
There is no reason you should get any weird exceptions if you just destroy
one window and create another one.
> I guess this is because wxWindow::Destory does not directly destroy the
> windows but rather remembers to delete it later in a idle phase to make
> sure no events get send to a deleted window.
Well, yes, but why should it be a problem?
> So I am somehow stuck on this and hope someone can tell me how
> something I try can be accomplished in a clean way.
Again, the best would be to not recreate the window at all, I don't think
there should be any reason to recreate the GUI objects if you don't really
need to restart the application. But your current approach should work too,
you probably just have a bug somewhere.
Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
More information about the wx-users
mailing list