[gnome-packagekit/glib2: 76/79] Mm



commit dc9497240635bda4284e7dfd42db013e79feda9e
Author: Richard Hughes <richard hughsie com>
Date:   Mon Oct 5 14:53:38 2009 +0100

    Mm

 src/gpk-dbus-task.c |   26 +++++++++++++++-----------
 1 files changed, 15 insertions(+), 11 deletions(-)
---
diff --git a/src/gpk-dbus-task.c b/src/gpk-dbus-task.c
index 94a858e..79ab37c 100644
--- a/src/gpk-dbus-task.c
+++ b/src/gpk-dbus-task.c
@@ -84,14 +84,13 @@ struct _GpkDbusTaskPrivate
 	guint			 timestamp;
 	gchar			*parent_title;
 	gchar			*parent_icon_name;
-	gchar			*error_details;
+	PkItemErrorCode		*cached_error_code;
 	gint			 timeout;
 	GpkHelperRun		*helper_run;
 	GpkHelperChooser	*helper_chooser;
 	DBusGMethodInvocation	*context;
 	gchar			**package_ids;
 	gchar			**files;
-	PkErrorCodeEnum		 last_exit_code;
 	GCancellable		*cancellable;
 	PkCatalog		*catalog;
 };
@@ -207,10 +206,17 @@ static void
 gpk_dbus_task_libnotify_cb (NotifyNotification *notification, gchar *action, gpointer data)
 {
 	GpkDbusTask *task = GPK_DBUS_TASK (data);
+	gchar *details;
 
+	if (task->priv->cached_error_code == NULL) {
+		egg_warning ("called show error with no error!");
+		return;
+	}
 	if (g_strcmp0 (action, "show-error-details") == 0) {
+		details = g_markup_escape_text (task->priv->cached_error_code->details, -1);
 		/* TRANSLATORS: detailed text about the error */
-		gpk_error_dialog (_("Error details"), _("Package Manager error details"), task->priv->error_details);
+		gpk_error_dialog (_("Error details"), _("Package Manager error details"), details);
+		g_free (details);
 	} else {
 		egg_warning ("unknown action id: %s", action);
 	}
@@ -284,9 +290,6 @@ gpk_dbus_task_handle_error (GpkDbusTask *dtask, PkItemErrorCode *error_item)
 	NotifyNotification *notification;
 	GtkWidget *widget;
 
-	/* save for later */
-	dtask->priv->last_exit_code = error_item->code;
-
 	/* ignore some errors */
 	if (error_item->code == PK_ERROR_ENUM_NO_LICENSE_AGREEMENT ||
 	    error_item->code == PK_ERROR_ENUM_PROCESS_KILL ||
@@ -306,8 +309,9 @@ gpk_dbus_task_handle_error (GpkDbusTask *dtask, PkItemErrorCode *error_item)
 	}
 
 	/* save this globally */
-	g_free (dtask->priv->error_details);
-	dtask->priv->error_details = g_markup_escape_text (error_item->details, -1);
+	if (dtask->priv->cached_error_code != NULL)
+		pk_item_error_code_unref (dtask->priv->cached_error_code);
+	dtask->priv->cached_error_code = pk_item_error_code_ref (error_item);
 
 	/* do the bubble */
 	notification = notify_notification_new (title, message, "help-browser", NULL);
@@ -2395,7 +2399,7 @@ gpk_dbus_task_init (GpkDbusTask *dtask)
 	dtask->priv->parent_window = NULL;
 	dtask->priv->parent_title = NULL;
 	dtask->priv->parent_icon_name = NULL;
-	dtask->priv->error_details = NULL;
+	dtask->priv->cached_error_code = NULL;
 	dtask->priv->context = NULL;
 	dtask->priv->cancellable = g_cancellable_new ();
 	dtask->priv->exit = PK_EXIT_ENUM_FAILED;
@@ -2406,7 +2410,6 @@ gpk_dbus_task_init (GpkDbusTask *dtask)
 	dtask->priv->show_finished = TRUE;
 	dtask->priv->show_warning = TRUE;
 	dtask->priv->timestamp = 0;
-	dtask->priv->last_exit_code = PK_ERROR_ENUM_UNKNOWN;
 
 	/* add application specific icons to search path */
 	gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
@@ -2469,7 +2472,8 @@ gpk_dbus_task_finalize (GObject *object)
 
 	g_free (dtask->priv->parent_title);
 	g_free (dtask->priv->parent_icon_name);
-	g_free (dtask->priv->error_details);
+	if (dtask->priv->cached_error_code != NULL)
+		pk_item_error_code_unref (dtask->priv->cached_error_code);
 	g_strfreev (dtask->priv->files);
 	g_strfreev (dtask->priv->package_ids);
 	g_object_unref (PK_CLIENT(dtask->priv->task));



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