projects
/
modest
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
* Fixes invalid unrefs when comparing merge folders
[modest]
/
src
/
modest-cache-mgr.c
diff --git
a/src/modest-cache-mgr.c
b/src/modest-cache-mgr.c
index
61fb100
..
c5bf3cb
100644
(file)
--- a/
src/modest-cache-mgr.c
+++ b/
src/modest-cache-mgr.c
@@
-29,6
+29,7
@@
#include <config.h>
#include <modest-cache-mgr.h>
#include <config.h>
#include <modest-cache-mgr.h>
+#include <stdio.h>
/* 'private'/'protected' functions */
static void modest_cache_mgr_class_init (ModestCacheMgrClass *klass);
/* 'private'/'protected' functions */
static void modest_cache_mgr_class_init (ModestCacheMgrClass *klass);
@@
-46,6
+47,7
@@
struct _ModestCacheMgrPrivate {
GHashTable *date_str_cache;
GHashTable *display_str_cache;
GHashTable *pixbuf_cache;
GHashTable *date_str_cache;
GHashTable *display_str_cache;
GHashTable *pixbuf_cache;
+ GHashTable *send_queue_cache;
};
#define MODEST_CACHE_MGR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
MODEST_TYPE_CACHE_MGR, \
};
#define MODEST_CACHE_MGR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
MODEST_TYPE_CACHE_MGR, \
@@
-69,7
+71,7
@@
modest_cache_mgr_get_type (void)
NULL, /* class finalize */
NULL, /* class data */
sizeof(ModestCacheMgr),
NULL, /* class finalize */
NULL, /* class data */
sizeof(ModestCacheMgr),
- 1, /* n_preallocs */
+ 0, /* n_preallocs */
(GInstanceInitFunc) modest_cache_mgr_init,
NULL
};
(GInstanceInitFunc) modest_cache_mgr_init,
NULL
};
@@
-94,10
+96,10
@@
modest_cache_mgr_class_init (ModestCacheMgrClass *klass)
static
static
-void pixbuf_unref (GObject *pixbuf)
+void my_object_unref (GObject *obj)
{
{
- if (pixbuf)
- g_object_unref (pixbuf);
+ if (obj)
+ g_object_unref (obj);
}
static void
}
static void
@@
-121,7
+123,12
@@
modest_cache_mgr_init (ModestCacheMgr *obj)
g_hash_table_new_full (g_str_hash, /* gchar* */
g_str_equal,
g_free, /* gchar*/
g_hash_table_new_full (g_str_hash, /* gchar* */
g_str_equal,
g_free, /* gchar*/
- (GDestroyNotify)pixbuf_unref);
+ (GDestroyNotify)my_object_unref);
+ priv->send_queue_cache =
+ g_hash_table_new_full (g_direct_hash, /* ptr */
+ g_direct_equal,
+ (GDestroyNotify)my_object_unref, /* ref'd GObject */
+ (GDestroyNotify)my_object_unref); /* ref'd GObject */
}
}
@@
-135,10
+142,11
@@
modest_cache_mgr_finalize (GObject *obj)
priv = MODEST_CACHE_MGR_GET_PRIVATE(obj);
modest_cache_mgr_flush_all (self);
priv = MODEST_CACHE_MGR_GET_PRIVATE(obj);
modest_cache_mgr_flush_all (self);
-
+
priv->date_str_cache = NULL;
priv->display_str_cache = NULL;
priv->pixbuf_cache = NULL;
priv->date_str_cache = NULL;
priv->display_str_cache = NULL;
priv->pixbuf_cache = NULL;
+ priv->send_queue_cache = NULL;
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
@@
-153,6
+161,8
@@
get_cache (ModestCacheMgrPrivate *priv, ModestCacheMgrCacheType type)
return priv->display_str_cache;
case MODEST_CACHE_MGR_CACHE_TYPE_PIXBUF:
return priv->pixbuf_cache;
return priv->display_str_cache;
case MODEST_CACHE_MGR_CACHE_TYPE_PIXBUF:
return priv->pixbuf_cache;
+ case MODEST_CACHE_MGR_CACHE_TYPE_SEND_QUEUE:
+ return priv->send_queue_cache;
default:
g_return_val_if_reached(NULL); /* should not happen */
}
default:
g_return_val_if_reached(NULL); /* should not happen */
}
@@
-173,6
+183,11
@@
modest_cache_mgr_get_cache (ModestCacheMgr* self, ModestCacheMgrCacheType type
GHashTable *cache;
g_return_val_if_fail (self, NULL);
GHashTable *cache;
g_return_val_if_fail (self, NULL);
+
+ if (!(type >= 0 && type <= MODEST_CACHE_MGR_CACHE_TYPE_NUM)) {
+ printf ("DEBUG: %s: incorrect type = %d\n", __FUNCTION__, type);
+ }
+
g_return_val_if_fail (type >= 0 && type <= MODEST_CACHE_MGR_CACHE_TYPE_NUM, NULL);
priv = MODEST_CACHE_MGR_GET_PRIVATE(self);
g_return_val_if_fail (type >= 0 && type <= MODEST_CACHE_MGR_CACHE_TYPE_NUM, NULL);
priv = MODEST_CACHE_MGR_GET_PRIVATE(self);
@@
-182,13
+197,6
@@
modest_cache_mgr_get_cache (ModestCacheMgr* self, ModestCacheMgrCacheType type
}
}
-static gboolean
-always_true (gpointer key, gpointer value, gpointer user_data)
-{
- return TRUE;
-}
-
-
void
modest_cache_mgr_flush (ModestCacheMgr *self, ModestCacheMgrCacheType type)
{
void
modest_cache_mgr_flush (ModestCacheMgr *self, ModestCacheMgrCacheType type)
{
@@
-197,13
+205,12
@@
modest_cache_mgr_flush (ModestCacheMgr *self, ModestCacheMgrCacheType type)
g_return_if_fail (self);
g_return_if_fail (type >= 0 && type <= MODEST_CACHE_MGR_CACHE_TYPE_NUM);
g_return_if_fail (self);
g_return_if_fail (type >= 0 && type <= MODEST_CACHE_MGR_CACHE_TYPE_NUM);
-
+
priv = MODEST_CACHE_MGR_GET_PRIVATE(self);
cache = get_cache (priv, type);
if (cache)
priv = MODEST_CACHE_MGR_GET_PRIVATE(self);
cache = get_cache (priv, type);
if (cache)
- g_hash_table_foreach_remove (cache, always_true, NULL);
- /* g_hash_table_remove_all (cache) in only available since GLIB 2.12 */
+ g_hash_table_destroy (cache);
}
}
@@
-212,7
+219,7
@@
modest_cache_mgr_flush_all (ModestCacheMgr *self)
{
int i;
g_return_if_fail (self);
{
int i;
g_return_if_fail (self);
-
+
for (i = 0; i != MODEST_CACHE_MGR_CACHE_TYPE_NUM; ++i)
modest_cache_mgr_flush (self, i);
}
for (i = 0; i != MODEST_CACHE_MGR_CACHE_TYPE_NUM; ++i)
modest_cache_mgr_flush (self, i);
}