First, I should state that I'm using GTK+ 2.6. It's all I've got no HP Unix, and even if I were inclined to compile source, I wouldn't be permitted. I have structure of a set of fields with all the widgets from my dialog window. I instantiate it as a pointer, so I can pass it as data. I use
MyStruct* this = g_malloc(sizeof(MyStruct)); Now, I've used g_malloc, so I'm supposed to use g_free. Only, I don't really know where. I can't put it at the bottom of the on_MyDialogMenuItem_clicked, because without the main loop here, the free will execute immediately. So, I put it in the on_buttonclose_clicked callback, passing in "this". I use the on_buttonclose_clicked callback for both the buttonclose clicked signal, and the window destroyed signal. g_signal_connect_swapped(G_OBJECT(this->dialog), "destroy", G_CALLBACK(on_buttonclose_clicked), this); Now, when I click the close button, it first destroys my dialog window, then frees the memory. Only when the function gtk_widget_destroy(this->dialog) is called, it generates a callback to on_buttonclose_clicked. (Oddly, it doesn't trigger the second time.) But it does generate an error which I thought was due to the fact that I'm freeing this and destroying my window twice. So, I've done everything I can think of, but my brain just doesn't want to seem to get a handle on this. I set a gboolean static variable in on_buttonclose_clicked, at first, and that sort of worked. Until I realized that when I ran the dialog a second time, the close button was permanently disabled. (Doh!) But it did work without error or warning when the button is clicked. So then I split the on_window_destroyed callback out of the on_buttonclose_clicked callback. I figured, I wouldn't care if I had a memory leak when the user killed the dialog via the window manager, since that wasn't likely to happen often with my nice looking, comfortably familiar close button around. Only, I'm still getting errors -- something about a GTK_IS_WIDGET assertion failing. I decided that lots of existing programs -- there must be one that launches concurrent windows as non-modal dialogs and surely there's a way around this. It's probably so obvious, it'd spit in my eye. Only, there isn't. I found only a couple, and they seem to work like mine, without of course, the g_free(this) or the this->dialog, since they all seem to not need multiple widgets or have g_malloc-ed widgets. Anyone know where I can find some clue-crumbs? I'm desparate for a clue here. Otoconia - Scientific confirmation of what my friends have known about me all my life -- that I have rocks in my head. _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list