diff options
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; | 
