[gnome-software/gnome-3-26] Fix GsAppRow lifetime issues when connecting to GsApp signals



commit ccf61cc315637b6ad76da0579f1a622b3363ce2d
Author: Kalev Lember <klember redhat com>
Date:   Fri Dec 8 15:32:59 2017 +0100

    Fix GsAppRow lifetime issues when connecting to GsApp signals
    
    mclasen noticed a critical while doing a flatpak update:
    
    15:06 < mclasen> I happened to have journalctl -f running while updating a flatpak in g-s:
    15:06 < mclasen> Dec 08 09:05:49 localhost.localdomain gnome-software[2353]: gs_app_row_unreveal: 
assertion 'GS_IS_APP_ROW (app_row)' failed
    15:06 < mclasen> Dec 08 09:05:49 localhost.localdomain gnome-software[2353]: invalid unclassed pointer in 
cast to 'GsAppRow'
    
    We're connecting to a GsApp signal and using GsAppRow as user_data,
    which means that GsApp can outlive the the user_data GsAppRow. This
    commit fixes the lifetime issue by switching to g_signal_connect_object
    which keeps the user_data object alive.

 src/gs-update-list.c  |    6 +++---
 src/gs-updates-page.c |    6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/src/gs-update-list.c b/src/gs-update-list.c
index 0180ce8..fe58c94 100644
--- a/src/gs-update-list.c
+++ b/src/gs-update-list.c
@@ -59,9 +59,9 @@ gs_update_list_add_app (GsUpdateList *update_list, GsApp *app)
                                    priv->sizegroup_image,
                                    priv->sizegroup_name,
                                    NULL);
-       g_signal_connect (app, "notify::state",
-                         G_CALLBACK (gs_update_list_app_state_notify_cb),
-                         app_row);
+       g_signal_connect_object (app, "notify::state",
+                                G_CALLBACK (gs_update_list_app_state_notify_cb),
+                                app_row, 0);
        gtk_widget_show (app_row);
 }
 
diff --git a/src/gs-updates-page.c b/src/gs-updates-page.c
index c7426d2..c621236 100644
--- a/src/gs-updates-page.c
+++ b/src/gs-updates-page.c
@@ -931,9 +931,9 @@ _add_app_row (GsUpdatesPage *self, GsApp *app)
                                    self->sizegroup_image,
                                    self->sizegroup_name,
                                    self->sizegroup_button);
-       g_signal_connect (app, "notify::state",
-                         G_CALLBACK (_app_state_notify_cb),
-                         app_row);
+       g_signal_connect_object (app, "notify::state",
+                                G_CALLBACK (_app_state_notify_cb),
+                                app_row, 0);
 }
 
 static void


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