[easytag] Return a gboolean from delete-event handler



commit 5442958d1ea34a992007bbb2bc047a9a5515387d
Author: David King <amigadave amigadave com>
Date:   Mon Mar 3 16:19:28 2014 +0000

    Return a gboolean from delete-event handler
    
    Avoid undefined behaviour (manifesting as a crash on Fedora Rawhide) by
    correctly returning a gboolean in the main window delete-event handler.
    If the delete event was propagated by accident, the default handler
    would destroy the window and lead to many subsequent problems.
    
    Thanks to Igor Gnatenko for the bug report.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=725568
    https://bugzilla.redhat.com/show_bug.cgi?id=1071563

 src/easytag.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/src/easytag.c b/src/easytag.c
index 29eeb82..7f6ecc7 100644
--- a/src/easytag.c
+++ b/src/easytag.c
@@ -156,6 +156,17 @@ static gboolean et_tag_field_on_key_press_event (GtkEntry *entry,
                                                  GdkEventKey *event,
                                                  gpointer user_data);
 
+static gboolean
+on_main_window_delete_event (GtkWidget *window,
+                             GdkEvent *event,
+                             gpointer user_data)
+{
+    Quit_MainWindow ();
+
+    /* Handled the event, so stop propagation. */
+    return TRUE;
+}
+
 /*
  * common_init:
  * @application: the application
@@ -225,8 +236,8 @@ common_init (GApplication *application)
     // This part is needed to set correctly the position of handle panes
     gtk_window_set_default_size(GTK_WINDOW(MainWindow),MAIN_WINDOW_WIDTH,MAIN_WINDOW_HEIGHT);
 
-    g_signal_connect(G_OBJECT(MainWindow),"delete_event",G_CALLBACK(Quit_MainWindow),NULL);
-    g_signal_connect(G_OBJECT(MainWindow),"destroy",G_CALLBACK(Quit_MainWindow),NULL);
+    g_signal_connect (MainWindow, "delete-event",
+                      G_CALLBACK (on_main_window_delete_event), NULL);
 
     /* Minimised window icon */
     gtk_widget_realize(MainWindow);


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