GNOME Bugzilla – Bug 333360
GtkAboutDialog deletes upon delete_event but hides upon close button click
Last modified: 2006-08-09 16:50:53 UTC
Running GTK+ 2.8.13 (also confirmed in 2.8.12): Clicking the X button in the top right (as displayed by the window manager) causes a delete_event to occur. This *destroys* the about dialog by default. However, if the user clicks close, close_cb() simply hides the dialog, rather than destroying it. These two actions should be consistent. Otherwise, apps such as xchat-gnome which expect the dialog to be hidden rather than destroyed will crash when trying to display the about dialog for the 2nd time. gtk_show_about_dialog() circumvents this by explicitly hooking up delete_event to gtk_widget_hide_on_delete(). Only direct users of gtk_about_dialog_new() are affected by this bug. Please consider this patch. I will also post a small test case in a few minutes time.
Created attachment 60641 [details] [review] Patch
Created attachment 60642 [details] test case To reproduce the problem: Compile + run test case Click "click me" An about dialog will appear. Close it by clicking on the X in the window manager decorations. Click "click me" again --> crash If you repeat the test, but this time click "Close" rather than X then no crash occurs.
I think it would be more consistent with other dialogs in gtk to move the close_cb setup in the other direction instead, ie make it the app responsibility to handle the response for an about dialog constructed with _new(). Not sure if that would be sufficiently backwards compatible, though.
2006-03-10 Matthias Clasen <mclasen@redhat.com> * gtk/gtkaboutdialog.c (gtk_show_about_dialog): Make the behaviour of the about dialog consistent with other dialogs in gtk. If the dialog is constructed with gtk_about_dialog_new(), the creator is reponsible for handling the response by hiding or closing the dialog. gtk_show_about_dialog() handles it by hiding the dialog. (#333360, Daniel Drake) * README.in: Mention this change.
This change causes my application (user interface built with glade) to crash. I'll come back with details after I investigate.
Yes, most users of gtk_about_dialog_new() will need to modify their programs. Probably the easiest thing to do is to connect delete_event of your about dialog to gtk_widget_hide_on_delete().
I'm not worried about source level modifications. Are you sure that this patch preserves the application binary interface?
I don't think thats entirely relevant, although this modification may have made the original bug more obvious. If your program crashes after this change, then please remember it is also trivially easy to crash it *before* this change was put in place. Take an older GTK+ version (e.g. 2.8.13) and run your application. Open the about dialog. Close the about dialog *using the window managers X button* in the top right. Open the about dialog again --> crash Both situations require a source code fix.
You are right about the crash, of course. I *thought* I tested this before, but apparently not. Thank you for drawing attention to this bug.
I understand this change is documented in the README but to a new gtk developer this behaviour should be documented on the reference API docs, no?