Re: How to delete object?!



      But as I say - _true_ delete routine fails(I temporary replace it with
      "gtk_widget_destroy"), so: when we get into "else" gialog is not NULL, but
      it can't be neither showed ("gtk_widget_show" dump core) nor raise
      ("gdk_window_raise" dump core) since it's deleted with
"gtk_widget_destroy",
      which is not _true_ delete function.


The problem is that  the gtk_widget_destroy is destroying the dialog,
but the static variable is never beening set back to NULL, so it tries
to raise the old destroyed dialog, and so crashes.

What you need to do is
static GtkWidget * dialog=NULL;
if (!dialog)
{
      dialog = gcp_dialog_new_show ();

      /* This will set dialog back to NULL when it is destroyed 
          NB: gtk_widget_destroyed, and not gtk_widget_destroy */
      gtk_signal_connect (GTK_OBJECT (dialog), "destroyed",
                                        GTK_SIGNAL_FUNC
(gtk_widget_destroyed), &dialog);
} else {
     /* Etc */
}

iain





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