Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2020-02-25 12:32:20 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-02-25 12:32:20 +0300
commitbd03fe1ab0d09aa7bb29bdcd3d57db772b1dadbd (patch)
tree1aa126db811b78cd97378bf919b55797bbc7834f /source/blender/editors
parentd94a3996a4e9436896873bd1141c7cea9ab6908e (diff)
Cleanup: avoid Operator.customdata cast which could lead to errors
Both save and save-as share utility functions which cast from customdata in an error prone way. Avoid this by passing image format data directly.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/space_image/image_ops.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index d6355bb88fe..a3fa03b18b7 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -2043,12 +2043,14 @@ static int image_save_options_init(Main *bmain,
return (ibuf != NULL);
}
-static void image_save_options_from_op(Main *bmain, ImageSaveOptions *opts, wmOperator *op)
+static void image_save_options_from_op(Main *bmain,
+ ImageSaveOptions *opts,
+ wmOperator *op,
+ ImageFormatData *imf)
{
- if (op->customdata) {
- ImageSaveData *isd = op->customdata;
+ if (imf) {
BKE_color_managed_view_settings_free(&opts->im_format.view_settings);
- opts->im_format = isd->im_format;
+ opts->im_format = *imf;
}
if (RNA_struct_property_is_set(op->ptr, "filepath")) {
@@ -2111,10 +2113,12 @@ static int image_save_as_exec(bContext *C, wmOperator *op)
Image *image = NULL;
ImageUser *iuser = NULL;
+ ImageFormatData *imf = NULL;
if (op->customdata) {
ImageSaveData *isd = op->customdata;
image = isd->image;
iuser = isd->iuser;
+ imf = &isd->im_format;
}
else {
image = image_from_context(C);
@@ -2127,7 +2131,7 @@ static int image_save_as_exec(bContext *C, wmOperator *op)
* these should be set on invoke or by the caller. */
image_save_options_init(bmain, &opts, image, iuser, false, false);
- image_save_options_from_op(bmain, &opts, op);
+ image_save_options_from_op(bmain, &opts, op, imf);
opts.do_newpath = true;
save_image_op(bmain, image, iuser, op, &opts);
@@ -2371,7 +2375,7 @@ static int image_save_exec(bContext *C, wmOperator *op)
if (image_save_options_init(bmain, &opts, image, iuser, false, false) == 0) {
return OPERATOR_CANCELLED;
}
- image_save_options_from_op(bmain, &opts, op);
+ image_save_options_from_op(bmain, &opts, op, NULL);
if (BLI_exists(opts.filepath) && BLI_file_is_writable(opts.filepath)) {
if (save_image_op(bmain, image, iuser, op, &opts)) {