diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2010-01-09 01:27:29 +0100 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2010-01-09 01:27:29 +0100 |
commit | 91a89808f1f9a19c6703706f1859c870b9884d05 (patch) | |
tree | 13483c15d505c2ebe2b5a02c8ba5f5b847e5c43e /preload.c | |
parent | acacdcd8521c29f1a2c893d4bf97445cb22a9e75 (diff) |
Store original pixbufs so that preloaded images can be properly resized.
load_pixbuf() will now load the original pixbuf, then draw the
pre-resized pixbuf (if any) while keeping the original loaded.
This way the image will be properly resized when needed.
Added mutex calls to preload_clear().
Diffstat (limited to 'preload.c')
-rw-r--r-- | preload.c | 31 |
1 files changed, 27 insertions, 4 deletions
@@ -24,7 +24,10 @@ static void preload_hash_table_free(gpointer data) { pt = data; - g_object_unref(pt->pb); + if(pt->pb) + g_object_unref(pt->pb); + + g_object_unref(pt->pb_orig); g_free(data); } @@ -169,7 +172,27 @@ void preload_start_thread(GtkWidget *thumbview, gint win_width, gint win_height) } void preload_clear() { + g_mutex_lock(preload_hashtable_mutex); g_hash_table_remove_all(hashtable); + g_mutex_unlock(preload_hashtable_mutex); +} + +void preload_clear_sized() { + GHashTableIter iter; + struct preload_hash_table_value_t *data; + + g_mutex_lock(preload_hashtable_mutex); + + g_hash_table_iter_init(&iter, hashtable); + + while(g_hash_table_iter_next(&iter, NULL, (gpointer)&data)) { + if(data->pb) { + g_object_unref(data->pb); + data->pb = NULL; + } + } + + g_mutex_unlock(preload_hashtable_mutex); } static void preload_add(const gchar *filename, gpointer data) { @@ -218,15 +241,15 @@ inline static void add_pixbuf(const gchar *filename, gpointer _data) { value = g_malloc(sizeof(struct preload_hash_table_value_t)); + value->pb_orig = orig; + if(pb) { value->pb = pb; value->width = width; value->height = height; value->ratio = ratio; - - g_object_unref(orig); } else { - value->pb = orig; + value->pb = NULL; value->width = 0; value->height = 0; value->ratio = 0; |