[gthumb/ext] stop the preloader correctly
- From: Paolo Bacchilega <paobac src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gthumb/ext] stop the preloader correctly
- Date: Fri, 28 Aug 2009 10:59:32 +0000 (UTC)
commit 4af4223340bd4ac7f6993d78c5e0ac33ad142adb
Author: Paolo Bacchilega <paobac src gnome org>
Date: Fri Aug 28 12:51:56 2009 +0200
stop the preloader correctly
[fixed bug #593323]
extensions/image_viewer/gth-image-viewer-page.c | 17 ++++++++++++
gthumb/gth-image-loader.c | 10 ++-----
gthumb/gth-image-preloader.c | 32 +++++------------------
3 files changed, 27 insertions(+), 32 deletions(-)
---
diff --git a/extensions/image_viewer/gth-image-viewer-page.c b/extensions/image_viewer/gth-image-viewer-page.c
index fcca66e..c33b8c1 100644
--- a/extensions/image_viewer/gth-image-viewer-page.c
+++ b/extensions/image_viewer/gth-image-viewer-page.c
@@ -273,6 +273,20 @@ image_preloader_requested_ready_cb (GthImagePreloader *preloader,
{
GthImageLoader *image_loader;
+ if (error != NULL) {
+ /*
+ char *msg;
+
+ msg = g_strdup_printf (_("Could not view the file \"%s\""), g_file_info_get_display_name (self->priv->file_data->info));
+ _gtk_error_dialog_from_gerror_show (GTK_WINDOW (self->priv->browser), msg, &error);
+
+ g_free (msg);
+ return;
+ */
+ g_clear_error (&error);
+ return;
+ }
+
image_loader = gth_image_preloader_get_loader (self->priv->preloader, gth_image_preloader_get_requested (self->priv->preloader));
if (image_loader == NULL)
return;
@@ -568,6 +582,9 @@ gth_image_viewer_page_real_view (GthViewerPage *base,
self = (GthImageViewerPage*) base;
g_return_if_fail (file_data != NULL);
+ if ((self->priv->file_data != NULL) && g_file_equal (file_data->file, self->priv->file_data->file))
+ return;
+
_g_object_unref (self->priv->file_data);
self->priv->file_data = gth_file_data_dup (file_data);
diff --git a/gthumb/gth-image-loader.c b/gthumb/gth-image-loader.c
index d962034..a73d075 100644
--- a/gthumb/gth-image-loader.c
+++ b/gthumb/gth-image-loader.c
@@ -21,13 +21,7 @@
*/
#include <config.h>
-/*
-#include <errno.h>
-#include <fcntl.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <unistd.h>
-*/
+#include <glib/gi18n.h>
#define GDK_PIXBUF_ENABLE_BACKEND
#include <gdk-pixbuf/gdk-pixbuf-animation.h>
#include <gtk/gtk.h>
@@ -239,6 +233,8 @@ load_image_thread (void *thread_data)
loader = gth_main_get_file_loader (gth_file_data_get_mime_type (file));
if (loader != NULL)
animation = loader (file, &error, -1, -1);
+ else
+ error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, _("No suitable loader available for this file type"));
}
}
diff --git a/gthumb/gth-image-preloader.c b/gthumb/gth-image-preloader.c
index 35718da..65334a5 100644
--- a/gthumb/gth-image-preloader.c
+++ b/gthumb/gth-image-preloader.c
@@ -64,11 +64,6 @@ struct _GthImagePreloaderPrivate {
* any signal. */
int current; /* This is the loader that has
* a loading underway. */
- gboolean stopped; /* Whether the preloader has
- * been stopped. */
- DoneFunc done_func; /* Function to call after
- * stopping the loader. */
- gpointer done_func_data;
guint load_id;
};
@@ -241,7 +236,6 @@ gth_image_preloader_init (GthImagePreloader *image_preloader)
image_preloader->priv->loader[i] = preloader_new (image_preloader);
image_preloader->priv->requested = -1;
image_preloader->priv->current = -1;
- image_preloader->priv->stopped = FALSE;
}
@@ -458,7 +452,6 @@ gth_image_preloader_load__step2 (LoadData *load_data)
load_data_free (load_data);
- image_preloader->priv->stopped = FALSE;
start_next_loader (image_preloader);
}
@@ -524,19 +517,6 @@ start_next_loader (GthImagePreloader *image_preloader)
Preloader *preloader;
char *uri;
- if (image_preloader->priv->stopped) {
- image_preloader->priv->current = -1;
- image_preloader->priv->stopped = FALSE;
-
- debug (DEBUG_INFO, "stopped");
-
- if (image_preloader->priv->done_func != NULL)
- (*image_preloader->priv->done_func) (image_preloader->priv->done_func_data);
- image_preloader->priv->done_func = NULL;
-
- return;
- }
-
preloader = requested_preloader (image_preloader);
if ((preloader != NULL)
&& (preloader->file_data != NULL)
@@ -590,16 +570,18 @@ gth_image_preloader_stop (GthImagePreloader *image_preloader,
DoneFunc done_func,
gpointer done_func_data)
{
+ Preloader *preloader;
+
if (image_preloader->priv->current == -1) {
debug (DEBUG_INFO, "stopped");
- if (done_func != NULL)
- (*done_func) (done_func_data);
+ call_when_idle (done_func, done_func_data);
return;
}
- image_preloader->priv->stopped = TRUE;
- image_preloader->priv->done_func = done_func;
- image_preloader->priv->done_func_data = done_func_data;
+ preloader = current_preloader (image_preloader);
+ image_preloader->priv->current = -1;
+
+ gth_image_loader_cancel (preloader->loader, done_func, done_func_data);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]