talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 05f600e5826ab4fd43e345b87bf1029c1fef48f7
parent 45ac11d4db29610c0b66e53ecef8aaea1ebbbc9e
Author: wwp <subscript@free.fr>
Date:   Fri,  3 Sep 2021 09:17:04 +0200

CID1443020: logically dead code. Rework image loading error detection.

Diffstat:
Msrc/image_viewer.c | 19+++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/src/image_viewer.c b/src/image_viewer.c @@ -96,14 +96,18 @@ static void image_viewer_load_image(ImageViewer *imageviewer) #endif g_object_unref(stream); - if (error != NULL) { + if (error) { g_warning("Couldn't load image: %s\n", error->message); + gtk_label_set_text(GTK_LABEL(imageviewer->error_lbl), _("Error:")); + gtk_label_set_text(GTK_LABEL(imageviewer->error_msg), error->message); + gtk_notebook_set_current_page(GTK_NOTEBOOK(imageviewer->notebook), 0); + gtk_widget_hide(imageviewer->load_button); g_error_free(error); return; } #if GDK_PIXBUF_MINOR >= 28 - if (gdk_pixbuf_animation_is_static_image(animation) + if (animation && gdk_pixbuf_animation_is_static_image(animation) || imageviewer->resize_img || imageviewer->fit_img_height) { pixbuf = gdk_pixbuf_animation_get_static_image(animation); g_object_ref(pixbuf); @@ -112,7 +116,6 @@ static void image_viewer_load_image(ImageViewer *imageviewer) #else if (imageviewer->resize_img || imageviewer->fit_img_height) { #endif - if (imageviewer->resize_img) { gtk_widget_get_allocation(imageviewer->scrolledwin, &allocation); pixbuf = claws_load_pixbuf_fitting(pixbuf, FALSE, @@ -124,15 +127,8 @@ static void image_viewer_load_image(ImageViewer *imageviewer) pixbuf = claws_load_pixbuf_fitting(pixbuf, FALSE, imageviewer->fit_img_height, -1, -1); } - if (error && !pixbuf && !animation) { - gtk_label_set_text(GTK_LABEL(imageviewer->error_lbl), _("Error:")); - gtk_label_set_text(GTK_LABEL(imageviewer->error_msg), error->message); - gtk_notebook_set_current_page(GTK_NOTEBOOK(imageviewer->notebook), 0); - gtk_widget_hide(imageviewer->load_button); - g_error_free(error); - } if (!pixbuf && !animation) { - g_warning("Can't load the image."); + g_warning("Couldn't load the image"); return; } @@ -144,7 +140,6 @@ static void image_viewer_load_image(ImageViewer *imageviewer) g_signal_handlers_block_by_func(G_OBJECT(imageviewer->scrolledwin), G_CALLBACK(scrolledwin_resize_cb), imageviewer); - gtk_widget_show(imageviewer->image); GTK_EVENTS_FLUSH(); g_signal_handlers_unblock_by_func(G_OBJECT(imageviewer->scrolledwin),