[gnome-bluetooth] Fix crash caused by invalid cast



commit 8329a6acf72304de2ae11ac5884610e4bbf77bec
Author: Joshua Lock <josh linux intel com>
Date:   Fri Oct 9 15:38:04 2009 +0100

    Fix crash caused by invalid cast
    
    I badly merged some branches before an earlier patch which resulted in a
    GtkButton being sent as the data to a callback which I was then casting to
    a MoblinPanel.
    
    This patch fixes that and aims to alleviate this in future by consistently
    passing self (a pointer to MoblinPanel) as the callback data.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=597910

 moblin/moblin-panel.c |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)
---
diff --git a/moblin/moblin-panel.c b/moblin/moblin-panel.c
index a414138..1eaaac9 100644
--- a/moblin/moblin-panel.c
+++ b/moblin/moblin-panel.c
@@ -197,7 +197,8 @@ static void
 send_file_button_clicked_cb (GtkButton *button,
                              gpointer   user_data)
 {
-	BluetoothChooser *chooser = BLUETOOTH_CHOOSER (user_data);
+	MoblinPanelPrivate *priv = MOBLIN_PANEL_GET_PRIVATE (user_data);
+	BluetoothChooser *chooser = BLUETOOTH_CHOOSER (priv->display);
 	GPtrArray *a;
 	GError *err = NULL;
 	guint i;
@@ -261,7 +262,8 @@ ensure_selection (BluetoothChooser *chooser, const gchar *path)
 static void
 remove_clicked_cb (GtkCellRenderer *cell, const gchar *path, gpointer user_data)
 {
-	BluetoothChooser *chooser = BLUETOOTH_CHOOSER (user_data);
+	MoblinPanelPrivate *priv = MOBLIN_PANEL_GET_PRIVATE (user_data);
+	BluetoothChooser *chooser = BLUETOOTH_CHOOSER (priv->display);
 	const gchar *address = NULL;
 	GValue value = { 0, };
 
@@ -281,7 +283,8 @@ remove_clicked_cb (GtkCellRenderer *cell, const gchar *path, gpointer user_data)
 static void
 browse_clicked (GtkCellRenderer *renderer, const gchar *path, gpointer user_data)
 {
-	BluetoothChooser *chooser = BLUETOOTH_CHOOSER (user_data);
+	MoblinPanelPrivate *priv = MOBLIN_PANEL_GET_PRIVATE (user_data);
+	BluetoothChooser *chooser = BLUETOOTH_CHOOSER (priv->display);
 	const gchar *address = NULL;
 	GValue value = { 0, };
 	gchar *cmd;
@@ -821,7 +824,7 @@ create_devices_page (MoblinPanel *self)
 
 	gtk_tree_view_column_set_cell_data_func (type_column, cell,
 						 browse_to_text, self, NULL);
-	g_signal_connect (cell, "activated", G_CALLBACK (browse_clicked), priv->display);
+	g_signal_connect (cell, "activated", G_CALLBACK (browse_clicked), self);
 
 	/* Add the connect button */
 	cell = mux_cell_renderer_text_new ();
@@ -835,7 +838,7 @@ create_devices_page (MoblinPanel *self)
 	gtk_tree_view_column_pack_end (type_column, cell, FALSE);
 	gtk_tree_view_column_set_cell_data_func (type_column, cell,
 						remove_to_icon, self, NULL);
-	g_signal_connect (cell, "activated", G_CALLBACK (remove_clicked_cb), priv->display);
+	g_signal_connect (cell, "activated", G_CALLBACK (remove_clicked_cb), self);
 
 	gtk_widget_show (priv->display);
 	gtk_container_add (GTK_CONTAINER (frame), priv->display);
@@ -910,9 +913,9 @@ create_devices_page (MoblinPanel *self)
 	priv->send_button = gtk_button_new_with_label (_("Send file from your computer"));
 	gtk_widget_show (priv->send_button);
 	g_signal_connect (priv->send_button, "clicked",
-                    G_CALLBACK (send_file_button_clicked_cb), priv->display);
+                    G_CALLBACK (send_file_button_clicked_cb), self);
 	g_signal_connect (priv->display, "selected-device-changed",
-			G_CALLBACK (selected_device_changed_cb), priv->send_button);
+			G_CALLBACK (selected_device_changed_cb), self);
 	gtk_box_pack_start (GTK_BOX (vbox), priv->send_button, FALSE, FALSE, 4);
 
 	return page;



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