unref-erencing a GtkWindow



Hello all,

While writting an MDI widget with GtkAda, in which, among other features, the
user can insert any kind of widget, including a toplevel GtkWindow), I
encountered the following problem:

It seems that one can not do a gtk_widget_unref() on a GtkWindow.
The following program results in a segmentation fault.

#include <gtk/gtk.h>

int main (int argc, char** argv) {
  GtkWidget* win;
  
  gtk_init (&argc, &argv);
  win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_widget_show_all (win);

  gtk_widget_unref (win);
  //    gtk_widget_destroy (win);

  gtk_main ();
}



Whereas if you replace the gtk_widget_unref() by the call to
gtk_widget_destroy(), the main loop is properly started.

Is this expected ?


What I am trying to achieve is that if the user as gtk_widget_ref()-ed the
widget before putting it in the MDI, then this widget is never destroyed, even
when removed from the MDI. This can be used for instance to always reuse the
same instance of the widget when the user wants to open a search dialog in an
IDE.
Therefore, I believe I shouldn't call gtk_widget_destroy() explicitely. Am I right ?

Any suggestion would be most welcome.

thanks in advance

Emmanuel
GtkAda-team



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