[gthumb: 33/40] thumb loader: fixed generation of thumbs with external scripts
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb: 33/40] thumb loader: fixed generation of thumbs with external scripts
- Date: Fri, 10 Sep 2010 16:58:58 +0000 (UTC)
commit cec72f5d89b26d41e1309c1e08da6f80ce3be1d4
Author: Paolo Bacchilega <paobac src gnome org>
Date: Thu Sep 9 21:47:30 2010 +0200
thumb loader: fixed generation of thumbs with external scripts
gthumb/gnome-desktop-thumbnail.c | 11 ++++++++++-
gthumb/gth-file-list.c | 7 ++++---
gthumb/gth-thumb-loader.c | 26 ++++++++++++++++++++++++--
3 files changed, 38 insertions(+), 6 deletions(-)
---
diff --git a/gthumb/gnome-desktop-thumbnail.c b/gthumb/gnome-desktop-thumbnail.c
index 50d2e18..aaa3c32 100644
--- a/gthumb/gnome-desktop-thumbnail.c
+++ b/gthumb/gnome-desktop-thumbnail.c
@@ -820,8 +820,17 @@ gnome_desktop_thumbnail_factory_generate_from_script (GnomeDesktopThumbnailFacto
expanded_script = expand_thumbnailing_script (script, size, uri, *tmpname);
if (g_shell_parse_argv (expanded_script, &argc, &argv, error))
- if (g_spawn_async (NULL, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, pid, error))
+ if (g_spawn_async (g_get_tmp_dir (),
+ argv,
+ NULL,
+ G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH,
+ NULL,
+ NULL,
+ pid,
+ error))
+ {
retval = TRUE;
+ }
g_free (expanded_script);
g_free (script);
diff --git a/gthumb/gth-file-list.c b/gthumb/gth-file-list.c
index d1883fd..30860b2 100644
--- a/gthumb/gth-file-list.c
+++ b/gthumb/gth-file-list.c
@@ -737,7 +737,8 @@ thumbnail_job_free (ThumbnailJob *job)
static void
thumbnail_job_cancel (ThumbnailJob *job)
{
- g_cancellable_cancel (job->cancellable);
+ if (! g_cancellable_is_cancelled (job->cancellable))
+ g_cancellable_cancel (job->cancellable);
}
@@ -1591,8 +1592,8 @@ _gth_file_list_update_thumb (GthFileList *file_list,
}
for (scan = file_list->priv->jobs; scan; scan = scan->next) {
- ThumbnailJob *job = scan->data;
- thumbnail_job_cancel (job);
+ ThumbnailJob *other_job = scan->data;
+ thumbnail_job_cancel (other_job);
}
file_list->priv->jobs = g_list_prepend (file_list->priv->jobs, job);
diff --git a/gthumb/gth-thumb-loader.c b/gthumb/gth-thumb-loader.c
index a9ddb8c..39150bc 100644
--- a/gthumb/gth-thumb-loader.c
+++ b/gthumb/gth-thumb-loader.c
@@ -25,6 +25,7 @@
#include <unistd.h>
#include <sys/types.h>
#include <signal.h>
+#include <glib/gstdio.h>
#define GDK_PIXBUF_ENABLE_BACKEND
#include <gtk/gtk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
@@ -43,7 +44,7 @@
#define THUMBNAIL_LARGE_SIZE 256
#define THUMBNAIL_NORMAL_SIZE 128
#define THUMBNAIL_DIR_PERMISSIONS 0700
-#define MAX_THUMBNAILER_LIFETIME 2000 /* kill the thumbnailer after this amount of time*/
+#define MAX_THUMBNAILER_LIFETIME 4000 /* kill the thumbnailer after this amount of time*/
#define CHECK_CANCELLABLE_DELAY 200
struct _GthThumbLoaderPrivate
@@ -291,6 +292,7 @@ typedef struct {
guint thumbnailer_watch;
guint thumbnailer_timeout;
guint cancellable_watch;
+ gboolean script_cancelled;
} LoadData;
@@ -600,6 +602,7 @@ check_cancellable_cb (gpointer user_data)
LoadData *load_data = user_data;
if (g_cancellable_is_cancelled (load_data->cancellable)) {
+ load_data->script_cancelled = TRUE;
kill_thumbnailer_cb (user_data);
return FALSE;
}
@@ -631,6 +634,24 @@ watch_thumbnailer_cb (GPid pid,
load_data->thumbnailer_pid = 0;
load_data->thumbnailer_watch = 0;
+ if (load_data->script_cancelled) {
+ GError *error;
+
+ if (load_data->thumbnailer_tmpfile != NULL) {
+ g_unlink (load_data->thumbnailer_tmpfile);
+ g_free (load_data->thumbnailer_tmpfile);
+ load_data->thumbnailer_tmpfile = NULL;
+ }
+
+ error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_CANCELLED, "script cancelled");
+ g_simple_async_result_set_from_error (load_data->simple, error);
+ g_simple_async_result_complete_in_idle (load_data->simple);
+
+ g_error_free (error);
+
+ return;
+ }
+
pixbuf = NULL;
if (status == 0)
pixbuf = gnome_desktop_thumbnail_factory_load_from_tempfile (self->priv->thumb_factory,
@@ -669,7 +690,7 @@ original_image_ready_cb (GObject *source_object,
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
g_simple_async_result_set_from_error (load_data->simple, error);
- g_simple_async_result_complete_in_idle (load_data->simple);
+ g_simple_async_result_complete_in_idle (load_data->simple);
return;
}
@@ -694,6 +715,7 @@ original_image_ready_cb (GObject *source_object,
load_data);
}
else {
+ g_clear_error (&error);
failed_to_load_original_image (self, load_data);
load_data_unref (load_data);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]