gtk_main_quit() and destruction

When gtk_main_quit() is invoked, are the destruction callbacks
properly called?  Specifically, I would expect the "destroy" callback
to be called after gtk_main_quit() is used to kill off the whole

Take this code: it sets up a window, realizes it, and adds a timeout
that makes sure gtk_main_quit() is called as soon as gtk_main_loop()
is entered.  Here I would expect the "destroy" handler to be invoked,
but apparently it isn't.

How do I make sure my "destroy" handler is invoked even in the face of
gtk_main_quit()?  I need it to make sure that some cleanups are done
(e.g. processes killed) when the windows associated to them get

Code follows:

#include <gtk/gtk.h>

destroy_handler (GtkWidget *ignored, gpointer happily_ignored)
  g_print ("hi\n");     /* #### This doesn't get printed. */

timeout_handler (gpointer ignored)
  gtk_main_quit ();
  return 0;

main (int argc, char **argv)
  GtkWidget *window;

  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_signal_connect (GTK_OBJECT (window), "destroy",
		      GTK_SIGNAL_FUNC (destroy_handler), NULL);
  gtk_widget_show (window);

  gtk_timeout_add (1, timeout_handler, NULL);
  gtk_main ();
  return 0;

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