Skip to content

Commit

Permalink
Fix issue introduced by 7dc0faf by doing more cleanup in gboolean vs …
Browse files Browse the repository at this point in the history
…int.

Fixes #17536
  • Loading branch information
TurboGit committed Sep 26, 2024
1 parent 5a1f7a8 commit 89ca157
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 24 deletions.
13 changes: 7 additions & 6 deletions src/common/mipmap_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -1464,7 +1464,7 @@ static void _init_8(uint8_t *buf,
uint8_t *tmp = 0;
int32_t thumb_width, thumb_height;
res = dt_imageio_large_thumbnail(filename, &tmp, &thumb_width, &thumb_height, color_space);
if(!res)
if(res)
{
// if the thumbnail is not large enough, we compute one
const dt_image_t *img2 = dt_image_cache_get(darktable.image_cache, imgid, 'r');
Expand Down Expand Up @@ -1528,10 +1528,11 @@ static void _init_8(uint8_t *buf,
// export with flags: ignore exif(don't load from disk), don't
// swap byte order, don't do hq processing, no upscaling and
// signal we want thumbnail export
res = dt_imageio_export_with_flags(imgid, "unused", &format, (dt_imageio_module_data_t *)&dat, TRUE, FALSE, FALSE,
FALSE, FALSE, TRUE, NULL, FALSE, FALSE, DT_COLORSPACE_NONE, NULL, DT_INTENT_LAST, NULL,
NULL, 1, 1, NULL, -1);
if(!res)
res = dt_imageio_export_with_flags
(imgid, "unused", &format, (dt_imageio_module_data_t *)&dat, TRUE, FALSE, FALSE,
FALSE, FALSE, TRUE, NULL, FALSE, FALSE, DT_COLORSPACE_NONE, NULL, DT_INTENT_LAST,
NULL, NULL, 1, 1, NULL, -1);
if(res)
{
dt_print(DT_DEBUG_CACHE,
"[mipmap_cache] generate mip %d for ID=%d from scratch\n",
Expand All @@ -1548,7 +1549,7 @@ static void _init_8(uint8_t *buf,
// dat.head.width, dat.head.height);

// any errors?
if(res)
if(!res)
{
// dt_print(DT_DEBUG_ALWAYS, "[mipmap_cache] could not process thumbnail!\n");
*width = *height = 0;
Expand Down
6 changes: 3 additions & 3 deletions src/dtgtk/thumbnail.c
Original file line number Diff line number Diff line change
Expand Up @@ -795,9 +795,9 @@ static gboolean _event_image_draw(GtkWidget *widget,
char path[PATH_MAX] = { 0 };
gboolean from_cache = TRUE;
dt_image_full_path(thumb->imgid, path, sizeof(path), &from_cache);
if(!dt_imageio_large_thumbnail(path, &full_res_thumb,
&full_res_thumb_wd, &full_res_thumb_ht,
&color_space))
if(dt_imageio_large_thumbnail(path, &full_res_thumb,
&full_res_thumb_wd, &full_res_thumb_ht,
&color_space))
{
// we look for focus areas
dt_focus_cluster_t full_res_focus[49];
Expand Down
28 changes: 14 additions & 14 deletions src/imageio/imageio.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ gboolean dt_imageio_large_thumbnail(const char *filename,
int32_t *height,
dt_colorspaces_color_profile_type_t *color_space)
{
int res = TRUE;
int res = FALSE;

uint8_t *buf = NULL;
char *mime_type = NULL;
Expand Down Expand Up @@ -185,7 +185,7 @@ gboolean dt_imageio_large_thumbnail(const char *filename,
goto error;
}

res = FALSE;
res = TRUE;
}
else
{
Expand Down Expand Up @@ -236,13 +236,13 @@ gboolean dt_imageio_large_thumbnail(const char *filename,
}
}

res = FALSE;
res = TRUE;

error_gm:
if(image) DestroyImage(image);
if(image_info) DestroyImageInfo(image_info);
DestroyExceptionInfo(&exception);
if(res) goto error;
if(!res) goto error;
#elif defined HAVE_IMAGEMAGICK
MagickWand *image = NULL;
MagickBooleanType mret;
Expand Down Expand Up @@ -287,11 +287,11 @@ gboolean dt_imageio_large_thumbnail(const char *filename,
goto error_im;
}

res = FALSE;
res = TRUE;

error_im:
DestroyMagickWand(image);
if(res) goto error;
if(!res) goto error;
#else
dt_print(DT_DEBUG_ALWAYS,
"[dt_imageio_large_thumbnail] error: The thumbnail image is not in "
Expand All @@ -301,7 +301,7 @@ gboolean dt_imageio_large_thumbnail(const char *filename,
#endif
}

if(res)
if(!res)
{
dt_print(DT_DEBUG_ALWAYS,
"[dt_imageio_large_thumbnail] error: Not a supported thumbnail "
Expand Down Expand Up @@ -706,9 +706,9 @@ gboolean dt_imageio_export(const dt_imgid_t imgid,
{
if(strcmp(format->mime(format_params), "x-copy") == 0)
/* This is a just a copy, skip process and just export */
return (format->write_image(format_params, filename, NULL, icc_type,
return format->write_image(format_params, filename, NULL, icc_type,
icc_filename, NULL, 0, imgid, num, total, NULL,
export_masks)) != 0;
export_masks) == 0;
else
{
const gboolean is_scaling =
Expand Down Expand Up @@ -1184,20 +1184,20 @@ gboolean dt_imageio_export_with_flags(const dt_imgid_t imgid,
const int length = dt_exif_read_blob(&exif_profile, pathname, imgid, sRGB,
processed_width, processed_height, FALSE);

res = (format->write_image(format_params, filename, outbuf, icc_type,
res = format->write_image(format_params, filename, outbuf, icc_type,
icc_filename, exif_profile, length, imgid,
num, total, &pipe, export_masks)) != 0;
num, total, &pipe, export_masks) == 0;

free(exif_profile);
}
else
{
res = (format->write_image(format_params, filename, outbuf, icc_type,
res = format->write_image(format_params, filename, outbuf, icc_type,
icc_filename, NULL, 0, imgid, num, total,
&pipe, export_masks)) != 0;
&pipe, export_masks) == 0;
}

if(res)
if(!res)
goto error;

/* now write xmp into that container, if possible */
Expand Down

0 comments on commit 89ca157

Please sign in to comment.