[gthumb] Removed local cache code from the batch ops and added some NULL checks
- From: Michael J. Chudobiak <mjc src gnome org>
- To: svn-commits-list gnome org
- Subject: [gthumb] Removed local cache code from the batch ops and added some NULL checks
- Date: Fri, 8 May 2009 15:50:35 -0400 (EDT)
commit 665e62d5044d000d84cddf1fcd5a9b5d65b80c92
Author: Michael J. Chudobiak <mjc avtechpulse com>
Date: Fri May 8 15:49:52 2009 -0400
Removed local cache code from the batch ops and added some NULL checks
---
libgthumb/file-data.c | 6 +++
libgthumb/file-utils.c | 3 ++
src/gth-batch-op.c | 80 +++++++++++++++++------------------------------
3 files changed, 38 insertions(+), 51 deletions(-)
diff --git a/libgthumb/file-data.c b/libgthumb/file-data.c
index 5d78475..5452035 100644
--- a/libgthumb/file-data.c
+++ b/libgthumb/file-data.c
@@ -114,6 +114,9 @@ file_data_new (const char *path)
{
FileData *fd;
+ if (path == NULL)
+ return NULL;
+
fd = g_new0 (FileData, 1);
fd->ref = 1;
@@ -371,6 +374,9 @@ gboolean
file_data_has_local_path (FileData *fd,
GtkWindow *window)
{
+ if (fd == NULL)
+ return FALSE;
+
/* TODO: this is where we could trying mounting unmounted remote URIs */
if (fd->local_path == NULL) {
char *message;
diff --git a/libgthumb/file-utils.c b/libgthumb/file-utils.c
index 0145c1b..d331930 100644
--- a/libgthumb/file-utils.c
+++ b/libgthumb/file-utils.c
@@ -992,6 +992,9 @@ get_utf8_display_name_from_uri (const char *escaped_uri)
GFile *gfile;
/* g_file_get_parse_name can handle escaped and unescaped uris */
+
+ if (escaped_uri == NULL)
+ return NULL;
if (strcmp (escaped_uri,"/") == 0) {
utf8_name = g_strdup ("/");
diff --git a/src/gth-batch-op.c b/src/gth-batch-op.c
index 9cbc822..8044b6d 100644
--- a/src/gth-batch-op.c
+++ b/src/gth-batch-op.c
@@ -434,40 +434,13 @@ show_rename_dialog (GthBatchOp *bop)
static void
-save_image_and_remove_original_step2 (const char *uri,
- GError *error,
- gpointer callback_data)
-{
- GthBatchOp *bop = callback_data;
- FileData *fd;
-
- if (error == NULL)
- PD(bop)->saved_list = g_list_prepend (PD(bop)->saved_list, g_strdup (PD(bop)->new_path));
-
- fd = PD(bop)->current_image->data;
- if (! same_uri (fd->path, PD(bop)->new_path)) {
- comment_copy (fd->path, PD(bop)->new_path);
- if (PD(bop)->remove_original) {
- file_unlink (fd->path);
- PD(bop)->deleted_list = g_list_prepend (PD(bop)->deleted_list, g_strdup (fd->path));
- }
- }
-
- load_next_image (bop);
-}
-
-
-static void
pixbuf_op_done_cb (GthPixbufOp *pixop,
gboolean completed,
GthBatchOp *bop)
{
GError *error = NULL;
- FileData *fd;
+ FileData *fd_new;
FileData *fd_old;
- char *local_file;
- char *old_local_file;
- GFile *old_local_gfile;
if (! completed) {
notify_termination (bop);
@@ -475,30 +448,35 @@ pixbuf_op_done_cb (GthPixbufOp *pixop,
}
fd_old = (FileData*) PD(bop)->current_image->data;
- old_local_gfile = g_file_new_for_uri (fd_old->path);
- old_local_file = gfile_get_path (old_local_gfile);
- g_object_unref (old_local_gfile);
-
- local_file = get_cache_filename_from_uri (PD(bop)->new_path);
- if (! _gdk_pixbuf_savev (pixop->dest,
- local_file,
- old_local_file,
- PD(bop)->image_type,
- PD(bop)->keys,
- PD(bop)->values,
- &error))
- {
- _gtk_error_dialog_from_gerror_run (PD(bop)->parent, &error);
- g_free (local_file);
- load_next_image (bop);
- return;
- }
- g_free (local_file);
- g_free (old_local_file);
+ fd_new = file_data_new (PD(bop)->new_path);
+
+ if (file_data_has_local_path (fd_new, PD(bop)->parent) &&
+ file_data_has_local_path (fd_old, PD(bop)->parent)) {
+ if (! _gdk_pixbuf_savev (pixop->dest,
+ fd_new->local_path,
+ fd_old->local_path,
+ PD(bop)->image_type,
+ PD(bop)->keys,
+ PD(bop)->values,
+ &error)) {
+ _gtk_error_dialog_from_gerror_run (PD(bop)->parent, &error);
+ }
- fd = file_data_new (PD(bop)->new_path);
- update_file_from_cache (fd, save_image_and_remove_original_step2, bop);
- file_data_unref (fd);
+ if (error == NULL) {
+ PD(bop)->saved_list = g_list_prepend (PD(bop)->saved_list, g_strdup (PD(bop)->new_path));
+
+ if (! same_uri (fd_old->path, fd_new->path)) {
+ comment_copy (fd_old->path, fd_new->path);
+ if (PD(bop)->remove_original) {
+ file_unlink (fd_old->path);
+ PD(bop)->deleted_list = g_list_prepend (PD(bop)->deleted_list, g_strdup (fd_old->path));
+ }
+ }
+ }
+ }
+
+ file_data_unref (fd_new);
+ load_next_image (bop);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]