Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue introduced by 7dc0faf by doing more cleanup in gboolean vs … #17537

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
32 changes: 16 additions & 16 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 Expand Up @@ -1244,7 +1244,7 @@ gboolean dt_imageio_export_with_flags(const dt_imgid_t imgid,

if(!thumbnail_export)
dt_set_backthumb_time(5.0);
return FALSE; // success
return TRUE; // success

error:
dt_dev_pixelpipe_cleanup(&pipe);
Expand All @@ -1254,7 +1254,7 @@ gboolean dt_imageio_export_with_flags(const dt_imgid_t imgid,

if(!thumbnail_export)
dt_set_backthumb_time(5.0);
return TRUE;
return FALSE;
}


Expand Down
4 changes: 2 additions & 2 deletions src/imageio/storage/disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,10 +468,10 @@ int store(dt_imageio_module_storage_t *self,
if(fail) return 1;

/* export image to file */
if(dt_imageio_export(imgid, filename, format, fdata, high_quality,
if(!dt_imageio_export(imgid, filename, format, fdata, high_quality,
upscale, TRUE, export_masks, icc_type,
icc_filename, icc_intent, self, sdata,
num, total, metadata) != 0)
num, total, metadata))
{
dt_print(DT_DEBUG_ALWAYS,
"[imageio_storage_disk] could not export to file: `%s'!\n",
Expand Down
4 changes: 2 additions & 2 deletions src/imageio/storage/email.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ int store(dt_imageio_module_storage_t *self,

attachment->file = g_build_filename(tmpdir, dirname, (char *)NULL);

if(dt_imageio_export(imgid, attachment->file, format, fdata, high_quality,
if(!dt_imageio_export(imgid, attachment->file, format, fdata, high_quality,
upscale, TRUE, export_masks, icc_type,
icc_filename, icc_intent, self, sdata, num, total, metadata) != 0)
icc_filename, icc_intent, self, sdata, num, total, metadata))
{
dt_print(DT_DEBUG_ALWAYS,
"[imageio_storage_email] could not export to file: `%s'!\n",
Expand Down
8 changes: 4 additions & 4 deletions src/imageio/storage/gallery.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,9 @@ int store(dt_imageio_module_storage_t *self,

// export image to file. need this to be able to access meaningful
// fdata->width and height below.
if(dt_imageio_export(imgid, filename, format, fdata, high_quality,
if(!dt_imageio_export(imgid, filename, format, fdata, high_quality,
upscale, TRUE, export_masks, icc_type,
icc_filename, icc_intent, self, sdata, num, total, metadata) != 0)
icc_filename, icc_intent, self, sdata, num, total, metadata))
{
dt_print(DT_DEBUG_ALWAYS,
"[imageio_storage_gallery] could not export to file: `%s'!\n", filename);
Expand Down Expand Up @@ -440,9 +440,9 @@ int store(dt_imageio_module_storage_t *self,
if(c <= filename || *c == '/') c = filename + strlen(filename);
ext = format->extension(fdata);
sprintf(c, "-thumb.%s", ext);
if(dt_imageio_export(imgid, filename, format, fdata, FALSE, TRUE, FALSE,
if(!dt_imageio_export(imgid, filename, format, fdata, FALSE, TRUE, FALSE,
export_masks, icc_type, icc_filename,
icc_intent, self, sdata, num, total, NULL) != 0)
icc_intent, self, sdata, num, total, NULL))
{
dt_print(DT_DEBUG_ALWAYS,
"[imageio_storage_gallery] could not export to file: `%s'!\n", filename);
Expand Down
4 changes: 2 additions & 2 deletions src/imageio/storage/piwigo.c
Original file line number Diff line number Diff line change
Expand Up @@ -1348,9 +1348,9 @@ int store(dt_imageio_module_storage_t *self,

dt_image_cache_read_release(darktable.image_cache, img);

if(dt_imageio_export(imgid, fname, format, fdata, high_quality, upscale,
if(!dt_imageio_export(imgid, fname, format, fdata, high_quality, upscale,
TRUE, export_masks, icc_type, icc_filename,
icc_intent, self, sdata, num, total, metadata) != 0)
icc_intent, self, sdata, num, total, metadata))
{
dt_print(DT_DEBUG_ALWAYS,
"[imageio_storage_piwigo] could not export to file: `%s'!\n",
Expand Down
4 changes: 2 additions & 2 deletions src/lua/luastorage.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ static int store_wrapper(struct dt_imageio_module_storage_t *self,

gchar *complete_name = g_build_filename(tmpdir, filename, (char *)NULL);

if(dt_imageio_export(imgid, complete_name, format, fdata, high_quality, upscale, TRUE, export_masks,
icc_type, icc_filename, icc_intent, self, self_data, num, total, metadata) != 0)
if(!dt_imageio_export(imgid, complete_name, format, fdata, high_quality, upscale, TRUE, export_masks,
icc_type, icc_filename, icc_intent, self, self_data, num, total, metadata))
{
dt_print(DT_DEBUG_ALWAYS,
"[lua] %s: could not export to file `%s'!\n", self->name(self), complete_name);
Expand Down
Loading