Skip to content

Commit 83be4b3

Browse files
committed
Fix issue introduced by 7dc0faf by doing more cleanup in gboolean vs int.
Fixes #17536
1 parent 83dfc4c commit 83be4b3

File tree

4 files changed

+25
-24
lines changed

4 files changed

+25
-24
lines changed

src/common/mipmap_cache.c

+7-6
Original file line numberDiff line numberDiff line change
@@ -1464,7 +1464,7 @@ static void _init_8(uint8_t *buf,
14641464
uint8_t *tmp = 0;
14651465
int32_t thumb_width, thumb_height;
14661466
res = dt_imageio_large_thumbnail(filename, &tmp, &thumb_width, &thumb_height, color_space);
1467-
if(!res)
1467+
if(res)
14681468
{
14691469
// if the thumbnail is not large enough, we compute one
14701470
const dt_image_t *img2 = dt_image_cache_get(darktable.image_cache, imgid, 'r');
@@ -1528,10 +1528,11 @@ static void _init_8(uint8_t *buf,
15281528
// export with flags: ignore exif(don't load from disk), don't
15291529
// swap byte order, don't do hq processing, no upscaling and
15301530
// signal we want thumbnail export
1531-
res = dt_imageio_export_with_flags(imgid, "unused", &format, (dt_imageio_module_data_t *)&dat, TRUE, FALSE, FALSE,
1532-
FALSE, FALSE, TRUE, NULL, FALSE, FALSE, DT_COLORSPACE_NONE, NULL, DT_INTENT_LAST, NULL,
1533-
NULL, 1, 1, NULL, -1);
1534-
if(!res)
1531+
res = dt_imageio_export_with_flags
1532+
(imgid, "unused", &format, (dt_imageio_module_data_t *)&dat, TRUE, FALSE, FALSE,
1533+
FALSE, FALSE, TRUE, NULL, FALSE, FALSE, DT_COLORSPACE_NONE, NULL, DT_INTENT_LAST,
1534+
NULL, NULL, 1, 1, NULL, -1);
1535+
if(res)
15351536
{
15361537
dt_print(DT_DEBUG_CACHE,
15371538
"[mipmap_cache] generate mip %d for ID=%d from scratch\n",
@@ -1548,7 +1549,7 @@ static void _init_8(uint8_t *buf,
15481549
// dat.head.width, dat.head.height);
15491550

15501551
// any errors?
1551-
if(res)
1552+
if(!res)
15521553
{
15531554
// dt_print(DT_DEBUG_ALWAYS, "[mipmap_cache] could not process thumbnail!\n");
15541555
*width = *height = 0;

src/dtgtk/thumbnail.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -795,9 +795,9 @@ static gboolean _event_image_draw(GtkWidget *widget,
795795
char path[PATH_MAX] = { 0 };
796796
gboolean from_cache = TRUE;
797797
dt_image_full_path(thumb->imgid, path, sizeof(path), &from_cache);
798-
if(!dt_imageio_large_thumbnail(path, &full_res_thumb,
799-
&full_res_thumb_wd, &full_res_thumb_ht,
800-
&color_space))
798+
if(dt_imageio_large_thumbnail(path, &full_res_thumb,
799+
&full_res_thumb_wd, &full_res_thumb_ht,
800+
&color_space))
801801
{
802802
// we look for focus areas
803803
dt_focus_cluster_t full_res_focus[49];

src/imageio/imageio.c

+14-14
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ gboolean dt_imageio_large_thumbnail(const char *filename,
153153
int32_t *height,
154154
dt_colorspaces_color_profile_type_t *color_space)
155155
{
156-
int res = TRUE;
156+
int res = FALSE;
157157

158158
uint8_t *buf = NULL;
159159
char *mime_type = NULL;
@@ -185,7 +185,7 @@ gboolean dt_imageio_large_thumbnail(const char *filename,
185185
goto error;
186186
}
187187

188-
res = FALSE;
188+
res = TRUE;
189189
}
190190
else
191191
{
@@ -236,13 +236,13 @@ gboolean dt_imageio_large_thumbnail(const char *filename,
236236
}
237237
}
238238

239-
res = FALSE;
239+
res = TRUE;
240240

241241
error_gm:
242242
if(image) DestroyImage(image);
243243
if(image_info) DestroyImageInfo(image_info);
244244
DestroyExceptionInfo(&exception);
245-
if(res) goto error;
245+
if(!res) goto error;
246246
#elif defined HAVE_IMAGEMAGICK
247247
MagickWand *image = NULL;
248248
MagickBooleanType mret;
@@ -287,11 +287,11 @@ gboolean dt_imageio_large_thumbnail(const char *filename,
287287
goto error_im;
288288
}
289289

290-
res = FALSE;
290+
res = TRUE;
291291

292292
error_im:
293293
DestroyMagickWand(image);
294-
if(res) goto error;
294+
if(!res) goto error;
295295
#else
296296
dt_print(DT_DEBUG_ALWAYS,
297297
"[dt_imageio_large_thumbnail] error: The thumbnail image is not in "
@@ -301,7 +301,7 @@ gboolean dt_imageio_large_thumbnail(const char *filename,
301301
#endif
302302
}
303303

304-
if(res)
304+
if(!res)
305305
{
306306
dt_print(DT_DEBUG_ALWAYS,
307307
"[dt_imageio_large_thumbnail] error: Not a supported thumbnail "
@@ -706,9 +706,9 @@ gboolean dt_imageio_export(const dt_imgid_t imgid,
706706
{
707707
if(strcmp(format->mime(format_params), "x-copy") == 0)
708708
/* This is a just a copy, skip process and just export */
709-
return (format->write_image(format_params, filename, NULL, icc_type,
709+
return format->write_image(format_params, filename, NULL, icc_type,
710710
icc_filename, NULL, 0, imgid, num, total, NULL,
711-
export_masks)) != 0;
711+
export_masks) == 0;
712712
else
713713
{
714714
const gboolean is_scaling =
@@ -1184,20 +1184,20 @@ gboolean dt_imageio_export_with_flags(const dt_imgid_t imgid,
11841184
const int length = dt_exif_read_blob(&exif_profile, pathname, imgid, sRGB,
11851185
processed_width, processed_height, FALSE);
11861186

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

11911191
free(exif_profile);
11921192
}
11931193
else
11941194
{
1195-
res = (format->write_image(format_params, filename, outbuf, icc_type,
1195+
res = format->write_image(format_params, filename, outbuf, icc_type,
11961196
icc_filename, NULL, 0, imgid, num, total,
1197-
&pipe, export_masks)) != 0;
1197+
&pipe, export_masks) == 0;
11981198
}
11991199

1200-
if(res)
1200+
if(!res)
12011201
goto error;
12021202

12031203
/* now write xmp into that container, if possible */

0 commit comments

Comments
 (0)