[gimp] Bug 701053 - Opening jpg files from Canon camera displays...
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 701053 - Opening jpg files from Canon camera displays...
- Date: Sun, 26 May 2013 19:32:46 +0000 (UTC)
commit 308431f7b6248c371660352f2c429243f7a6a44b
Author: Michael Natterer <mitch gimp org>
Date: Sun May 26 21:26:08 2013 +0200
Bug 701053 - Opening jpg files from Canon camera displays...
...PNG Description encoding error.
Don't unconditionally display all error messages from thumbnail saving.
Instead, return the error from gimp_imagefile_create_thumbnai()
and gimp_imagefile_save_thumbnail() and display it only if thumbnail
creation was the actual user-intended action (like clicking the preview
in a file dialog). Do not display the error when thumbnailing is just
a side effect of loading/saving an image.
app/actions/documents-commands.c | 16 +++++++--
app/core/gimpimagefile.c | 64 +++++++++++++++++++-------------------
app/core/gimpimagefile.h | 50 +++++++++++++++--------------
app/file/file-open.c | 3 +-
app/file/file-save.c | 3 +-
app/file/file-utils.c | 3 +-
app/widgets/gimpthumbbox.c | 15 ++++++--
7 files changed, 87 insertions(+), 67 deletions(-)
---
diff --git a/app/actions/documents-commands.c b/app/actions/documents-commands.c
index 7a0758f..e44f386 100644
--- a/app/actions/documents-commands.c
+++ b/app/actions/documents-commands.c
@@ -267,10 +267,18 @@ documents_recreate_preview_cmd_callback (GtkAction *action,
if (imagefile && gimp_container_have (container, GIMP_OBJECT (imagefile)))
{
- gimp_imagefile_create_thumbnail (imagefile,
- context, NULL,
- context->gimp->config->thumbnail_size,
- FALSE);
+ GError *error = NULL;
+
+ if (! gimp_imagefile_create_thumbnail (imagefile,
+ context, NULL,
+ context->gimp->config->thumbnail_size,
+ FALSE, &error))
+ {
+ gimp_message_literal (context->gimp,
+ NULL , GIMP_MESSAGE_ERROR,
+ error->message);
+ g_clear_error (&error);
+ }
}
}
diff --git a/app/core/gimpimagefile.c b/app/core/gimpimagefile.c
index c98de5b..772fc37 100644
--- a/app/core/gimpimagefile.c
+++ b/app/core/gimpimagefile.c
@@ -317,23 +317,26 @@ gimp_imagefile_update (GimpImagefile *imagefile)
}
}
-void
-gimp_imagefile_create_thumbnail (GimpImagefile *imagefile,
- GimpContext *context,
- GimpProgress *progress,
- gint size,
- gboolean replace)
+gboolean
+gimp_imagefile_create_thumbnail (GimpImagefile *imagefile,
+ GimpContext *context,
+ GimpProgress *progress,
+ gint size,
+ gboolean replace,
+ GError **error)
{
GimpImagefilePrivate *private;
GimpThumbnail *thumbnail;
GimpThumbState image_state;
- g_return_if_fail (GIMP_IS_IMAGEFILE (imagefile));
- g_return_if_fail (GIMP_IS_CONTEXT (context));
- g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
+ g_return_val_if_fail (GIMP_IS_IMAGEFILE (imagefile), FALSE);
+ g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
+ g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+ /* thumbnailing is disabled, we successfully did nothing */
if (size < 1)
- return;
+ return TRUE;
private = GET_PRIVATE (imagefile);
@@ -352,12 +355,14 @@ gimp_imagefile_create_thumbnail (GimpImagefile *imagefile,
gint width = 0;
gint height = 0;
const gchar *mime_type = NULL;
- GError *error = NULL;
const Babl *format = NULL;
gint num_layers = -1;
g_object_ref (imagefile);
+ /* don't pass the error, we're only interested in errors from
+ * actual thumbnail saving
+ */
image = file_open_thumbnail (private->gimp, context, progress,
thumbnail->image_uri, size,
&mime_type, &width, &height,
@@ -373,6 +378,9 @@ gimp_imagefile_create_thumbnail (GimpImagefile *imagefile,
{
GimpPDBStatusType status;
+ /* don't pass the error, we're only interested in errors
+ * from actual thumbnail saving
+ */
image = file_open_image (private->gimp, context, progress,
thumbnail->image_uri,
thumbnail->image_uri,
@@ -388,7 +396,7 @@ gimp_imagefile_create_thumbnail (GimpImagefile *imagefile,
{
success = gimp_imagefile_save_thumb (imagefile,
image, size, replace,
- &error);
+ error);
g_object_unref (image);
}
@@ -396,20 +404,16 @@ gimp_imagefile_create_thumbnail (GimpImagefile *imagefile,
{
success = gimp_thumbnail_save_failure (thumbnail,
"GIMP " GIMP_VERSION,
- &error);
+ error);
gimp_imagefile_update (imagefile);
}
g_object_unref (imagefile);
- if (! success)
- {
- gimp_message_literal (private->gimp,
- G_OBJECT (progress), GIMP_MESSAGE_ERROR,
- error->message);
- g_clear_error (&error);
- }
+ return success;
}
+
+ return TRUE;
}
/* The weak version doesn't ref the imagefile but deals gracefully
@@ -443,7 +447,8 @@ gimp_imagefile_create_thumbnail_weak (GimpImagefile *imagefile,
g_object_add_weak_pointer (G_OBJECT (imagefile), (gpointer) &imagefile);
- gimp_imagefile_create_thumbnail (local, context, progress, size, replace);
+ gimp_imagefile_create_thumbnail (local, context, progress, size, replace,
+ NULL);
if (imagefile)
{
@@ -487,17 +492,18 @@ gimp_imagefile_check_thumbnail (GimpImagefile *imagefile)
}
gboolean
-gimp_imagefile_save_thumbnail (GimpImagefile *imagefile,
- const gchar *mime_type,
- GimpImage *image)
+gimp_imagefile_save_thumbnail (GimpImagefile *imagefile,
+ const gchar *mime_type,
+ GimpImage *image,
+ GError **error)
{
GimpImagefilePrivate *private;
gint size;
gboolean success = TRUE;
- GError *error = NULL;
g_return_val_if_fail (GIMP_IS_IMAGEFILE (imagefile), FALSE);
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
private = GET_PRIVATE (imagefile);
@@ -510,13 +516,7 @@ gimp_imagefile_save_thumbnail (GimpImagefile *imagefile,
success = gimp_imagefile_save_thumb (imagefile,
image, size, FALSE,
- &error);
- if (! success)
- {
- gimp_message_literal (private->gimp, NULL, GIMP_MESSAGE_ERROR,
- error->message);
- g_clear_error (&error);
- }
+ error);
}
return success;
diff --git a/app/core/gimpimagefile.h b/app/core/gimpimagefile.h
index 20a62f2..7e76c63 100644
--- a/app/core/gimpimagefile.h
+++ b/app/core/gimpimagefile.h
@@ -55,30 +55,32 @@ struct _GimpImagefileClass
GType gimp_imagefile_get_type (void) G_GNUC_CONST;
-GimpImagefile * gimp_imagefile_new (Gimp *gimp,
- const gchar *uri);
-
-GimpThumbnail * gimp_imagefile_get_thumbnail (GimpImagefile *imagefile);
-GIcon * gimp_imagefile_get_gicon (GimpImagefile *imagefile);
-
-void gimp_imagefile_set_mime_type (GimpImagefile *imagefile,
- const gchar *mime_type);
-void gimp_imagefile_update (GimpImagefile *imagefile);
-void gimp_imagefile_create_thumbnail (GimpImagefile *imagefile,
- GimpContext *context,
- GimpProgress *progress,
- gint size,
- gboolean replace);
-void gimp_imagefile_create_thumbnail_weak (GimpImagefile *imagefile,
- GimpContext *context,
- GimpProgress *progress,
- gint size,
- gboolean replace);
-gboolean gimp_imagefile_check_thumbnail (GimpImagefile *imagefile);
-gboolean gimp_imagefile_save_thumbnail (GimpImagefile *imagefile,
- const gchar *mime_type,
- GimpImage *image);
-const gchar * gimp_imagefile_get_desc_string (GimpImagefile *imagefile);
+GimpImagefile * gimp_imagefile_new (Gimp *gimp,
+ const gchar *uri);
+
+GimpThumbnail * gimp_imagefile_get_thumbnail (GimpImagefile *imagefile);
+GIcon * gimp_imagefile_get_gicon (GimpImagefile *imagefile);
+
+void gimp_imagefile_set_mime_type (GimpImagefile *imagefile,
+ const gchar *mime_type);
+void gimp_imagefile_update (GimpImagefile *imagefile);
+gboolean gimp_imagefile_create_thumbnail (GimpImagefile *imagefile,
+ GimpContext *context,
+ GimpProgress *progress,
+ gint size,
+ gboolean replace,
+ GError **error);
+void gimp_imagefile_create_thumbnail_weak (GimpImagefile *imagefile,
+ GimpContext *context,
+ GimpProgress *progress,
+ gint size,
+ gboolean replace);
+gboolean gimp_imagefile_check_thumbnail (GimpImagefile *imagefile);
+gboolean gimp_imagefile_save_thumbnail (GimpImagefile *imagefile,
+ const gchar *mime_type,
+ GimpImage *image,
+ GError **error);
+const gchar * gimp_imagefile_get_desc_string (GimpImagefile *imagefile);
#endif /* __GIMP_IMAGEFILE_H__ */
diff --git a/app/file/file-open.c b/app/file/file-open.c
index 82a215a..781baeb 100644
--- a/app/file/file-open.c
+++ b/app/file/file-open.c
@@ -498,7 +498,8 @@ file_open_with_proc_and_display (Gimp *gimp,
/* no need to save a thumbnail if there's a good one already */
if (! gimp_imagefile_check_thumbnail (imagefile))
{
- gimp_imagefile_save_thumbnail (imagefile, mime_type, image);
+ gimp_imagefile_save_thumbnail (imagefile, mime_type, image,
+ NULL);
}
}
}
diff --git a/app/file/file-save.c b/app/file/file-save.c
index 6ea2e80..360f97a 100644
--- a/app/file/file-save.c
+++ b/app/file/file-save.c
@@ -219,7 +219,8 @@ file_save (Gimp *gimp,
/* only save a thumbnail if we are saving as XCF, see bug #25272 */
if (GIMP_PROCEDURE (file_proc)->proc_type == GIMP_INTERNAL)
- gimp_imagefile_save_thumbnail (imagefile, file_proc->mime_type, image);
+ gimp_imagefile_save_thumbnail (imagefile, file_proc->mime_type, image,
+ NULL);
}
else if (status != GIMP_PDB_CANCEL)
{
diff --git a/app/file/file-utils.c b/app/file/file-utils.c
index 20d5093..284f932 100644
--- a/app/file/file-utils.c
+++ b/app/file/file-utils.c
@@ -464,7 +464,8 @@ file_utils_save_thumbnail (GimpImage *image,
GimpImagefile *imagefile;
imagefile = gimp_imagefile_new (image->gimp, uri);
- success = gimp_imagefile_save_thumbnail (imagefile, NULL, image);
+ success = gimp_imagefile_save_thumbnail (imagefile, NULL, image,
+ NULL);
g_object_unref (imagefile);
}
diff --git a/app/widgets/gimpthumbbox.c b/app/widgets/gimpthumbbox.c
index 53ad0d0..df9ec11 100644
--- a/app/widgets/gimpthumbbox.c
+++ b/app/widgets/gimpthumbbox.c
@@ -693,10 +693,17 @@ gimp_thumb_box_create_thumbnail (GimpThumbBox *box,
(gimp_thumbnail_peek_thumb (thumb, size) < GIMP_THUMB_STATE_FAILED &&
! gimp_thumbnail_has_failed (thumb)))
{
- gimp_imagefile_create_thumbnail (box->imagefile, box->context,
- progress,
- size,
- !force);
+ GError *error = NULL;
+
+ if (! gimp_imagefile_create_thumbnail (box->imagefile, box->context,
+ progress,
+ size, ! force, &error))
+ {
+ gimp_message_literal (box->context->gimp,
+ G_OBJECT (progress), GIMP_MESSAGE_ERROR,
+ error->message);
+ g_clear_error (&error);
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]