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



Hi Gus,

many thanks for the reply. I found a solution. I am bound to finishing the
event-loop earlier. Therefore now I do

gtk_widget_destroy(GTK_WIDGET(window));
if(!gtk_main_level()) {
  while(gtk_events_pending()) gtk_main_iteration_do(FALSE);
}

ciao
  Stefan

Gus Koppel wrote:
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.
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


-- 
      \|/            Stefan Kost
     <@ @>           private            business
+-oOO-(_)-OOo------------------------------------------------------ - - -  -   -
|       __  Address  Simildenstr. 5     HTWK Leipzig, Fb IMN, Postfach 301166
|      ///           04277 Leipzig      04251 Leipzig
| __  ///            Germany            Germany
| \\\///    Phone    +49341 2253538     +49341 30766101
|  \__/     EMail    st_kost_at_gmx.net kost_at_imn.htwk-leipzig.de
|           WWW      www.sonicpulse.de  www.imn.htwk-leipzig.de/~kost/about.html
===-=-=--=---=---------------------------------- - - -  -    -

Attachment: kost.vcf
Description: Vcard



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