[gnome-software] Keep a ref on back entry focus widget
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Keep a ref on back entry focus widget
- Date: Mon, 15 Sep 2014 22:12:10 +0000 (UTC)
commit f8b4a55fbca80884eafaeb127a2c63e8cc695c52
Author: Kalev Lember <kalevlember gmail com>
Date: Mon Sep 15 23:43:07 2014 +0200
Keep a ref on back entry focus widget
This fixes a crash when going back from Details to the Installed view
after having removed an app.
src/gs-shell.c | 7 ++++++-
src/gs-update-dialog.c | 9 ++++++++-
2 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/src/gs-shell.c b/src/gs-shell.c
index a33e078..fb8ec72 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -227,10 +227,14 @@ save_back_entry (GsShell *shell)
{
GsShellPrivate *priv = shell->priv;
BackEntry *entry;
+ GtkWidget *focus;
entry = g_new0 (BackEntry, 1);
entry->mode = priv->mode;
- entry->focus = gtk_window_get_focus (priv->main_window);
+
+ focus = gtk_window_get_focus (priv->main_window);
+ if (focus != NULL)
+ entry->focus = g_object_ref (focus);
if (priv->mode == GS_SHELL_MODE_CATEGORY) {
entry->category = gs_shell_category_get_category (priv->shell_category);
@@ -247,6 +251,7 @@ save_back_entry (GsShell *shell)
static void
free_back_entry (BackEntry *entry)
{
+ g_clear_object (&entry->focus);
g_clear_object (&entry->category);
g_clear_object (&entry->app);
g_free (entry);
diff --git a/src/gs-update-dialog.c b/src/gs-update-dialog.c
index 1e6def0..11b276d 100644
--- a/src/gs-update-dialog.c
+++ b/src/gs-update-dialog.c
@@ -61,11 +61,16 @@ save_back_entry (GsUpdateDialog *dialog)
{
GsUpdateDialogPrivate *priv = gs_update_dialog_get_instance_private (dialog);
BackEntry *entry;
+ GtkWidget *focus;
entry = g_slice_new0 (BackEntry);
entry->stack_page = g_strdup (gtk_stack_get_visible_child_name (GTK_STACK (priv->stack)));
entry->title = g_strdup (gtk_window_get_title (GTK_WINDOW (dialog)));
- entry->focus = gtk_window_get_focus (GTK_WINDOW (dialog));
+ entry->focus = g_object_ref (gtk_window_get_focus (GTK_WINDOW (dialog)));
+
+ focus = gtk_window_get_focus (GTK_WINDOW (dialog));
+ if (focus != NULL)
+ entry->focus = g_object_ref (focus);
g_queue_push_head (priv->back_entry_stack, entry);
}
@@ -73,6 +78,8 @@ save_back_entry (GsUpdateDialog *dialog)
static void
back_entry_free (BackEntry *entry)
{
+ if (entry->focus != NULL)
+ g_object_unref (entry->focus);
g_free (entry->stack_page);
g_free (entry->title);
g_slice_free (BackEntry, entry);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]