[evolution] Add e_activity_get_last_known_text().
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Add e_activity_get_last_known_text().
- Date: Sun, 7 Jul 2013 00:06:27 +0000 (UTC)
commit 682328cded9d509f121fcd0fc550919e9532ffb9
Author: Matthew Barnes <mbarnes redhat com>
Date: Sat Jul 6 11:42:41 2013 -0400
Add e_activity_get_last_known_text().
Evolution is still occasionally getting stuck on shutdown, and although
the evolution-shell log domain shows debug messages for activities that
are preventing shutdown, they frequently look like this:
(evolution:13534): evolution-shell-DEBUG: 5 active 'mail' activities:
(evolution:13534): evolution-shell-DEBUG: * (no description)
(evolution:13534): evolution-shell-DEBUG: * (no description)
(evolution:13534): evolution-shell-DEBUG: * (no description)
(evolution:13534): evolution-shell-DEBUG: * (no description)
(evolution:13534): evolution-shell-DEBUG: * (no description)
I think the lack of descriptions is from CamelOperations popping all
their pushed messages, which is correct behavior but doesn't help us
debug the problem.
e_activity_get_last_known_text() returns the most recent _non-empty_
text value set on the EActivity. So our debug message can fall back
to that if the EActivity has no description at shutdown:
(evolution:13534): evolution-shell-DEBUG: * (was "blah, blah, blah")
.../evolution-util/evolution-util-sections.txt | 1 +
e-util/e-activity.c | 32 ++++++++++++++++++++
e-util/e-activity.h | 1 +
shell/e-shell-backend.c | 6 ++++
4 files changed, 40 insertions(+), 0 deletions(-)
---
diff --git a/doc/reference/evolution-util/evolution-util-sections.txt
b/doc/reference/evolution-util/evolution-util-sections.txt
index 7ea0569..8e0c917 100644
--- a/doc/reference/evolution-util/evolution-util-sections.txt
+++ b/doc/reference/evolution-util/evolution-util-sections.txt
@@ -43,6 +43,7 @@ e_activity_get_state
e_activity_set_state
e_activity_get_text
e_activity_set_text
+e_activity_get_last_known_text
e_activity_handle_cancellation
<SUBSECTION Standard>
E_ACTIVITY
diff --git a/e-util/e-activity.c b/e-util/e-activity.c
index 87b8449..e3beb59 100644
--- a/e-util/e-activity.c
+++ b/e-util/e-activity.c
@@ -37,6 +37,7 @@
#include <stdarg.h>
#include <glib/gi18n.h>
#include <camel/camel.h>
+#include <libedataserver/libedataserver.h>
#include "e-util-enumtypes.h"
@@ -51,6 +52,7 @@ struct _EActivityPrivate {
gchar *icon_name;
gchar *text;
+ gchar *last_known_text;
gdouble percent;
/* Whether to emit a runtime warning if we
@@ -214,6 +216,7 @@ activity_finalize (GObject *object)
g_free (priv->icon_name);
g_free (priv->text);
+ g_free (priv->last_known_text);
/* Chain up to parent's finalize() method. */
G_OBJECT_CLASS (e_activity_parent_class)->finalize (object);
@@ -726,6 +729,8 @@ void
e_activity_set_text (EActivity *activity,
const gchar *text)
{
+ gchar *last_known_text = NULL;
+
g_return_if_fail (E_IS_ACTIVITY (activity));
if (g_strcmp0 (activity->priv->text, text) == 0)
@@ -734,10 +739,37 @@ e_activity_set_text (EActivity *activity,
g_free (activity->priv->text);
activity->priv->text = g_strdup (text);
+ /* See e_activity_get_last_known_text(). */
+ last_known_text = e_util_strdup_strip (text);
+ if (last_known_text != NULL) {
+ g_free (activity->priv->last_known_text);
+ activity->priv->last_known_text = last_known_text;
+ }
+
g_object_notify (G_OBJECT (activity), "text");
}
/**
+ * e_activity_get_last_known_text:
+ * @activity: an #EActivity
+ *
+ * Returns the last non-empty #EActivity:text value, so it's possible to
+ * identify what the @activity <emphasis>was</emphasis> doing even if it
+ * currently has no description.
+ *
+ * Mostly useful for debugging.
+ *
+ * Returns: a descriptive message, or %NULL
+ **/
+const gchar *
+e_activity_get_last_known_text (EActivity *activity)
+{
+ g_return_val_if_fail (E_IS_ACTIVITY (activity), NULL);
+
+ return activity->priv->last_known_text;
+}
+
+/**
* e_activity_handle_cancellation:
* @activity: an #EActivity
* @error: a #GError, or %NULL
diff --git a/e-util/e-activity.h b/e-util/e-activity.h
index 9309fe1..1c2cc4e 100644
--- a/e-util/e-activity.h
+++ b/e-util/e-activity.h
@@ -90,6 +90,7 @@ void e_activity_set_state (EActivity *activity,
const gchar * e_activity_get_text (EActivity *activity);
void e_activity_set_text (EActivity *activity,
const gchar *text);
+const gchar * e_activity_get_last_known_text (EActivity *activity);
gboolean e_activity_handle_cancellation (EActivity *activity,
const GError *error);
diff --git a/shell/e-shell-backend.c b/shell/e-shell-backend.c
index 5f7666b..e4926c5 100644
--- a/shell/e-shell-backend.c
+++ b/shell/e-shell-backend.c
@@ -105,12 +105,18 @@ shell_backend_debug_list_activities (EShellBackend *shell_backend)
for (link = head; link != NULL; link = g_list_next (link)) {
EActivity *activity = E_ACTIVITY (link->data);
gchar *description;
+ const gchar *was;
description = e_activity_describe (activity);
+ was = e_activity_get_last_known_text (activity);
+
if (description != NULL)
g_debug ("* %s", description);
+ else if (was != NULL)
+ g_debug ("* (was \"%s\")", was);
else
g_debug ("* (no description)");
+
g_free (description);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]