Fix #134162: Crash when opening a file with a compositor image node.

Yet another remaining case of non-trivial data created with C-style
allocation.

While 4.4 and previous did not exhibit the crash, the invalid code
responsible for this crash is present here as well, and it would be
dangerous not to fix it.
This commit is contained in:
Bastien Montagne
2025-02-06 11:07:04 +01:00
parent ca65379d70
commit 734af8206c
2 changed files with 9 additions and 4 deletions

View File

@@ -27,7 +27,7 @@ struct bContext;
#define TEMPLATE_SEARCH_TEXTBUT_HEIGHT UI_UNIT_Y
struct RNAUpdateCb {
PointerRNA ptr;
PointerRNA ptr = {};
PropertyRNA *prop;
};

View File

@@ -697,7 +697,7 @@ static void uiblock_layer_pass_buttons(uiLayout *layout,
}
struct RNAUpdateCb {
PointerRNA ptr;
PointerRNA ptr = {};
PropertyRNA *prop;
ImageUser *iuser;
};
@@ -789,11 +789,16 @@ void uiTemplateImage(uiLayout *layout,
}
/* Set custom callback for property updates. */
RNAUpdateCb *cb = static_cast<RNAUpdateCb *>(MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb"));
RNAUpdateCb *cb = MEM_new<RNAUpdateCb>(__func__);
cb->ptr = *ptr;
cb->prop = prop;
cb->iuser = iuser;
UI_block_funcN_set(block, rna_update_cb, cb, nullptr);
UI_block_funcN_set(block,
rna_update_cb,
cb,
nullptr,
but_func_argN_free<RNAUpdateCb>,
but_func_argN_copy<RNAUpdateCb>);
/* Disable editing if image was modified, to avoid losing changes. */
const bool is_dirty = BKE_image_is_dirty(ima);