Re: window survives gtk_widget_destroy(GTK_WIDGET(window));



Stefan Kost wrote:

anyone an idea how it can be that a window do not closes after I do

gtk_widget_hide_all(GTK_WIDGET(window));
gtk_widget_destroy(GTK_WIDGET(window));

The event-loop has been exited and a lengthy calculation will start.
The window remains open until the application shuts-down.

I have registered a signal handler for the window as
  void sighandler_window_on_destroy(GtkWidget *gtk_widget, gpointer
  data); via
  g_signal_connect(GTK_OBJECT(window),
                   "destroy",G_CALLBACK(sighandler_window_on_destroy)
                   ,...);

this will be triggered, but the window stays open. I do open and close
windows before as well and this works. Does closing a window required
a running-event loop? Or has anyone an expalnation for it?

I don't know for sure but I would guess so. I think a better strategy is
1. destroy your window
2. let GTK+ process pending events in the main loop
3. exit your GTK+ main loop.

Coded it would look something like this:

    gtk_widget_destroy (GTK_WIDGET (window));
    while (gtk_events_pending ())
        gtk_main_iteration ();
    gtk_main_quit ();

Btw, destruction automatically involves hiding of widgets.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]