Fix: Mismatched new/delete in annotation and text operators

Pull Request: https://projects.blender.org/blender/blender/pulls/137404
This commit is contained in:
Brecht Van Lommel
2025-04-21 17:21:43 +02:00
parent 3c9f33ad07
commit cf5fc4dcec
2 changed files with 14 additions and 19 deletions

View File

@@ -2189,18 +2189,17 @@ static void annotation_draw_apply_event(
/* operator 'redo' (i.e. after changing some properties, but also for repeat last) */
static wmOperatorStatus annotation_draw_exec(bContext *C, wmOperator *op)
{
tGPsdata *p = nullptr;
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
/* try to initialize context data needed while drawing */
if (!annotation_draw_init(C, op, nullptr)) {
if (op->customdata) {
MEM_freeN(op->customdata);
}
tGPsdata *p = static_cast<tGPsdata *>(op->customdata);
MEM_delete(p);
op->customdata = nullptr;
return OPERATOR_CANCELLED;
}
p = static_cast<tGPsdata *>(op->customdata);
tGPsdata *p = static_cast<tGPsdata *>(op->customdata);
/* loop over the stroke RNA elements recorded (i.e. progress of mouse movement),
* setting the relevant values in context at each step, then applying
@@ -2256,8 +2255,6 @@ static wmOperatorStatus annotation_draw_exec(bContext *C, wmOperator *op)
/* start of interactive drawing part of operator */
static wmOperatorStatus annotation_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
tGPsdata *p = nullptr;
/* support for tablets eraser pen */
if (annotation_is_tablet_eraser_active(event)) {
RNA_enum_set(op->ptr, "mode", GP_PAINTMODE_ERASER);
@@ -2265,13 +2262,13 @@ static wmOperatorStatus annotation_draw_invoke(bContext *C, wmOperator *op, cons
/* try to initialize context data needed while drawing */
if (!annotation_draw_init(C, op, event)) {
if (op->customdata) {
MEM_freeN(op->customdata);
}
tGPsdata *p = static_cast<tGPsdata *>(op->customdata);
MEM_delete(p);
op->customdata = nullptr;
return OPERATOR_CANCELLED;
}
p = static_cast<tGPsdata *>(op->customdata);
tGPsdata *p = static_cast<tGPsdata *>(op->customdata);
/* if empty erase capture and finish */
if (p->status == GP_STATUS_CAPTURE) {

View File

@@ -404,7 +404,6 @@ static wmOperatorStatus text_open_exec(bContext *C, wmOperator *op)
SpaceText *st = CTX_wm_space_text(C);
Main *bmain = CTX_data_main(C);
Text *text;
PropertyPointerRNA *pprop;
char filepath[FILE_MAX];
const bool internal = RNA_boolean_get(op->ptr, "internal");
@@ -412,20 +411,18 @@ static wmOperatorStatus text_open_exec(bContext *C, wmOperator *op)
text = BKE_text_load_ex(bmain, filepath, BKE_main_blendfile_path(bmain), internal);
PropertyPointerRNA *pprop = static_cast<PropertyPointerRNA *>(op->customdata);
if (!text) {
if (op->customdata) {
MEM_freeN(op->customdata);
}
MEM_delete(pprop);
op->customdata = nullptr;
return OPERATOR_CANCELLED;
}
if (!op->customdata) {
if (!pprop) {
text_open_init(C, op);
}
/* hook into UI */
pprop = static_cast<PropertyPointerRNA *>(op->customdata);
if (pprop->prop) {
PointerRNA idptr = RNA_id_pointer_create(&text->id);
RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr, nullptr);
@@ -2788,7 +2785,8 @@ static void scroll_exit(bContext *C, wmOperator *op)
st->runtime->scroll_ofs_px[1] = 0;
ED_area_tag_redraw(CTX_wm_area(C));
MEM_freeN(op->customdata);
MEM_freeN(tsc);
op->customdata = nullptr;
}
static wmOperatorStatus text_scroll_modal(bContext *C, wmOperator *op, const wmEvent *event)