aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2011-04-25 19:08:14 +0800
committerEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2011-04-25 19:45:21 +0800
commitd0b3485a2c13036b0b7eb8a1700e477358f0a9f3 (patch)
treea01272828aa38ee00f6f0ccef0c21ed49c77ff79
parente8395743f049f47e211d2301fe5d2323dc69d873 (diff)
downloadgsoc2013-empathy-d0b3485a2c13036b0b7eb8a1700e477358f0a9f3.tar
gsoc2013-empathy-d0b3485a2c13036b0b7eb8a1700e477358f0a9f3.tar.gz
gsoc2013-empathy-d0b3485a2c13036b0b7eb8a1700e477358f0a9f3.tar.bz2
gsoc2013-empathy-d0b3485a2c13036b0b7eb8a1700e477358f0a9f3.tar.lz
gsoc2013-empathy-d0b3485a2c13036b0b7eb8a1700e477358f0a9f3.tar.xz
gsoc2013-empathy-d0b3485a2c13036b0b7eb8a1700e477358f0a9f3.tar.zst
gsoc2013-empathy-d0b3485a2c13036b0b7eb8a1700e477358f0a9f3.zip
Stop processing logger calls when unneeded
-rw-r--r--libempathy-gtk/empathy-log-window.c44
1 files changed, 36 insertions, 8 deletions
diff --git a/libempathy-gtk/empathy-log-window.c b/libempathy-gtk/empathy-log-window.c
index 37f79b9ae..ede4edf16 100644
--- a/libempathy-gtk/empathy-log-window.c
+++ b/libempathy-gtk/empathy-log-window.c
@@ -82,6 +82,9 @@ typedef struct
TplActionChain *chain;
TplLogManager *log_manager;
+ /* Used to cancel logger calls when no longer needed */
+ guint count;
+
/* List of owned TplLogSearchHits, free with tpl_log_search_hit_free */
GList *hits;
@@ -192,6 +195,7 @@ typedef struct
GDate *date;
TplEventTypeMask event_mask;
EventSubtype subtype;
+ guint count;
} Ctx;
static Ctx *
@@ -200,7 +204,8 @@ ctx_new (EmpathyLogWindow *window,
TplEntity *entity,
GDate *date,
TplEventTypeMask event_mask,
- EventSubtype subtype)
+ EventSubtype subtype,
+ guint count)
{
Ctx *ctx = g_slice_new0 (Ctx);
@@ -213,6 +218,7 @@ ctx_new (EmpathyLogWindow *window,
ctx->date = _date_copy (date);
ctx->event_mask = event_mask;
ctx->subtype = subtype;
+ ctx->count = count;
return ctx;
}
@@ -1034,7 +1040,7 @@ populate_events_from_search_hits (GList *accounts,
Ctx *ctx;
ctx = ctx_new (log_window, hit->account, hit->target, hit->date,
- event_mask, subtype);
+ event_mask, subtype, log_window->count);
_tpl_action_chain_append (log_window->chain,
get_events_for_date, ctx);
}
@@ -1396,6 +1402,9 @@ log_manager_got_entities_cb (GObject *manager,
if (log_window == NULL)
goto out;
+ if (log_window->count != ctx->count)
+ goto out;
+
if (!tpl_log_manager_get_entities_finish (TPL_LOG_MANAGER (manager),
result, &entities, &error))
{
@@ -1542,13 +1551,16 @@ log_window_who_populate (EmpathyLogWindow *window)
log_window_who_changed_cb,
window);
+ _tpl_action_chain_clear (window->chain);
+ window->count++;
+
if (!all_accounts && account == NULL)
{
return;
}
else if (!all_accounts)
{
- ctx = ctx_new (window, account, NULL, NULL, 0, 0);
+ ctx = ctx_new (window, account, NULL, NULL, 0, 0, window->count);
_tpl_action_chain_append (window->chain, get_entities_for_account, ctx);
}
else
@@ -1563,7 +1575,7 @@ log_window_who_populate (EmpathyLogWindow *window)
{
account = l->data;
- ctx = ctx_new (window, account, NULL, NULL, 0, 0);
+ ctx = ctx_new (window, account, NULL, NULL, 0, 0, window->count);
_tpl_action_chain_append (window->chain,
get_entities_for_account, ctx);
}
@@ -2109,6 +2121,9 @@ log_window_got_messages_for_date_cb (GObject *manager,
if (log_window == NULL)
goto out;
+ if (log_window->count != ctx->count)
+ goto out;
+
if (!tpl_log_manager_get_events_for_date_finish (TPL_LOG_MANAGER (manager),
result, &events, &error))
{
@@ -2202,6 +2217,9 @@ log_window_get_messages_for_date (EmpathyLogWindow *window,
anytime = g_date_new_dmy (2, 1, -1);
separator = g_date_new_dmy (1, 1, -1);
+ _tpl_action_chain_clear (window->chain);
+ window->count++;
+
for (acc = accounts, targ = targets;
acc != NULL && targ != NULL;
acc = acc->next, targ = targ->next)
@@ -2214,7 +2232,8 @@ log_window_get_messages_for_date (EmpathyLogWindow *window,
{
Ctx *ctx;
- ctx = ctx_new (window, account, target, date, event_mask, subtype);
+ ctx = ctx_new (window, account, target, date, event_mask, subtype,
+ window->count);
_tpl_action_chain_append (window->chain, get_events_for_date, ctx);
}
else
@@ -2238,7 +2257,8 @@ log_window_get_messages_for_date (EmpathyLogWindow *window,
if (g_date_compare (d, anytime) != 0 &&
g_date_compare (d, separator) != 0)
{
- ctx = ctx_new (window, account, target, d, event_mask, subtype);
+ ctx = ctx_new (window, account, target, d,
+ event_mask, subtype, window->count);
_tpl_action_chain_append (window->chain, get_events_for_date, ctx);
}
}
@@ -2269,7 +2289,11 @@ log_manager_got_dates_cb (GObject *manager,
GDate *date = NULL;
GError *error = NULL;
- g_return_if_fail (log_window != NULL);
+ if (log_window == NULL)
+ goto out;
+
+ if (log_window->count != ctx->count)
+ goto out;
if (!tpl_log_manager_get_dates_finish (TPL_LOG_MANAGER (manager),
result, &dates, &error))
@@ -2393,6 +2417,9 @@ log_window_chats_get_messages (EmpathyLogWindow *window,
/* Clear all current messages shown in the textview */
gtk_tree_store_clear (window->store_events);
+ _tpl_action_chain_clear (window->chain);
+ window->count++;
+
/* If there's a search use the returned hits */
if (window->hits != NULL)
{
@@ -2426,7 +2453,8 @@ log_window_chats_get_messages (EmpathyLogWindow *window,
{
TpAccount *account = acc->data;
TplEntity *target = targ->data;
- Ctx *ctx = ctx_new (window, account, target, NULL, event_mask, 0);
+ Ctx *ctx = ctx_new (window, account, target, NULL, event_mask, 0,
+ window->count);
_tpl_action_chain_append (window->chain, get_dates_for_entity, ctx);
}