[gthumb] fixed crash when starting the slideshow with a folder without images



commit 44d0c5fd76abed30d8d8ef5695e96f0d73cbd69e
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sun Jul 4 23:21:26 2010 +0200

    fixed crash when starting the slideshow with a folder without images

 extensions/slideshow/actions.c |   20 +++++++++++++++++++-
 gthumb/gth-image-preloader.c   |    4 ++++
 2 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/extensions/slideshow/actions.c b/extensions/slideshow/actions.c
index 0b8be91..6d6db17 100644
--- a/extensions/slideshow/actions.c
+++ b/extensions/slideshow/actions.c
@@ -35,6 +35,8 @@ gth_browser_activate_action_view_slideshow (GtkAction  *action,
 {
 	GList        *items;
 	GList        *file_list;
+	GList        *filtered_list;
+	GList        *scan;
 	GthProjector *projector;
 	GtkWidget    *slideshow;
 	GthFileData  *location;
@@ -47,6 +49,21 @@ gth_browser_activate_action_view_slideshow (GtkAction  *action,
 	else
 		file_list = gth_file_list_get_files (GTH_FILE_LIST (gth_browser_get_file_list (browser)), items);
 
+	filtered_list = NULL;
+	for (scan = file_list; scan; scan = scan->next) {
+		GthFileData *file_data = scan->data;
+
+		if (_g_mime_type_is_image (gth_file_data_get_mime_type (file_data)))
+			filtered_list = g_list_prepend (filtered_list, g_object_ref (file_data));
+	}
+	filtered_list = g_list_reverse (filtered_list);
+
+	if (filtered_list == NULL) {
+		_g_object_list_unref (file_list);
+		_gtk_tree_path_list_free (items);
+		return;
+	}
+
 	location = gth_browser_get_location_data (browser);
 	if (g_file_info_get_attribute_boolean (location->info, "slideshow::personalize"))
 		transition_id = g_strdup (g_file_info_get_attribute_string (location->info, "slideshow::transition"));
@@ -63,7 +80,7 @@ gth_browser_activate_action_view_slideshow (GtkAction  *action,
 	if ((projector == NULL) || (strcmp (transition_id, "none") == 0))
 		projector = &default_projector;
 
-	slideshow = gth_slideshow_new (projector, browser, file_list);
+	slideshow = gth_slideshow_new (projector, browser, filtered_list);
 
 	if (g_file_info_get_attribute_boolean (location->info, "slideshow::personalize")) {
 		gth_slideshow_set_delay (GTH_SLIDESHOW (slideshow), g_file_info_get_attribute_int32 (location->info, "slideshow::delay"));
@@ -110,6 +127,7 @@ gth_browser_activate_action_view_slideshow (GtkAction  *action,
 
 	_g_object_list_unref (transitions);
 	g_free (transition_id);
+	_g_object_list_unref (filtered_list);
 	_g_object_list_unref (file_list);
 	_gtk_tree_path_list_free (items);
 }
diff --git a/gthumb/gth-image-preloader.c b/gthumb/gth-image-preloader.c
index 4952bed..6dcf5f8 100644
--- a/gthumb/gth-image-preloader.c
+++ b/gthumb/gth-image-preloader.c
@@ -106,6 +106,8 @@ image_loader_ready_cb (GthImageLoader *il,
 	preloader->loaded = (error == NULL);
 	preloader->error  = (error != NULL);
 
+	g_object_ref (image_preloader);
+
 	if (preloader == requested_preloader (image_preloader)) {
 		g_signal_emit (G_OBJECT (image_preloader),
 			       gth_image_preloader_signals[REQUESTED_READY],
@@ -116,6 +118,8 @@ image_loader_ready_cb (GthImageLoader *il,
 	}
 
 	image_preloader->priv->load_id = g_idle_add (load_next, image_preloader);
+
+	g_object_unref (image_preloader);
 }
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]