Skip to content

Commit

Permalink
Minor GIMP protocol fix
Browse files Browse the repository at this point in the history
If dt_int() fails and there is some gimp operation pending we should also report a gimp protocol error.

While being here use printf() instead of fprintf(stdout, "") for protol messages for simplicity.
  • Loading branch information
jenshannoschwalm authored and TurboGit committed Dec 1, 2024
1 parent 77fa502 commit 542e43a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/common/gimp.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ gboolean dt_export_gimp_file(const dt_imgid_t imgid)
NULL, // icc_filename
DT_INTENT_PERCEPTUAL,
NULL); // &metadata
fprintf(stdout, "<<<gimp\n%s%s\n", path, thumb ? ".jpg" : ".exr");
printf("<<<gimp\n%s%s\n", path, thumb ? ".jpg" : ".exr");
if(thumb)
{
dt_image_t *image = dt_image_cache_get(darktable.image_cache, imgid, 'r');
fprintf(stdout, "%i %i\n", image->width, image->height);
printf("%i %i\n", image->width, image->height);
dt_image_cache_read_release(darktable.image_cache, image);
}
fprintf(stdout, "gimp>>>\n");
printf("gimp>>>\n");
return TRUE;
}

Expand Down
13 changes: 9 additions & 4 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,16 @@ int main(int argc, char *argv[])
g_setenv("GTK_CSD", "0", TRUE);
#endif

if(dt_init(argc, argv, TRUE, TRUE, NULL)) exit(1);
if(dt_init(argc, argv, TRUE, TRUE, NULL))
{
if(darktable.gimp.mode)
printf("\n<<<gimp\nerror\ngimp>>>\n");
exit(1);
}

if(dt_check_gimpmode_ok("version"))
{
fprintf(stdout, "\n<<<gimp\n%d\ngimp>>>\n", DT_GIMP_VERSION);
printf("\n<<<gimp\n%d\ngimp>>>\n", DT_GIMP_VERSION);
exit(0);
}

Expand All @@ -117,7 +122,7 @@ int main(int argc, char *argv[])
|| (dt_check_gimpmode("thumb") && !dt_check_gimpmode_ok("thumb"))
|| darktable.gimp.error)
{
fprintf(stdout, "\n<<<gimp\nerror\ngimp>>>\n");
printf("\n<<<gimp\nerror\ngimp>>>\n");
exit(1);
}

Expand All @@ -143,7 +148,7 @@ int main(int argc, char *argv[])
dt_cleanup();

if(darktable.gimp.mode && darktable.gimp.error)
fprintf(stdout, "\n<<<gimp\nerror\ngimp>>>\n");
printf("\n<<<gimp\nerror\ngimp>>>\n");

#ifdef _WIN32
if(redirect_output)
Expand Down

0 comments on commit 542e43a

Please sign in to comment.