Fix #120731: sculpt trim tool crash #120733
|
@ -598,9 +598,6 @@ static void gesture_end(bContext & /*C*/, gesture::GestureData &gesture_data)
|
|||
|
||||
static void init_operation(gesture::GestureData &gesture_data, wmOperator &op)
|
||||
{
|
||||
gesture_data.operation = reinterpret_cast<gesture::Operation *>(
|
||||
MEM_cnew<TrimOperation>(__func__));
|
||||
|
||||
TrimOperation *trim_operation = (TrimOperation *)gesture_data.operation;
|
||||
|
||||
trim_operation->op.begin = gesture_begin;
|
||||
|
@ -725,8 +722,10 @@ static int gesture_box_exec(bContext *C, wmOperator *op)
|
|||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
init_operation(*gesture_data, *op);
|
||||
gesture_data->operation = reinterpret_cast<gesture::Operation *>(
|
||||
MEM_cnew<TrimOperation>(__func__));
|
||||
initialize_cursor_info(*C, *op, *gesture_data);
|
||||
init_operation(*gesture_data, *op);
|
||||
|
||||
|
||||
gesture::apply(*C, *gesture_data, *op);
|
||||
return OPERATOR_FINISHED;
|
||||
|
@ -754,8 +753,10 @@ static int gesture_lasso_exec(bContext *C, wmOperator *op)
|
|||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
init_operation(*gesture_data, *op);
|
||||
gesture_data->operation = reinterpret_cast<gesture::Operation *>(
|
||||
MEM_cnew<TrimOperation>(__func__));
|
||||
initialize_cursor_info(*C, *op, *gesture_data);
|
||||
init_operation(*gesture_data, *op);
|
||||
|
||||
gesture::apply(*C, *gesture_data, *op);
|
||||
return OPERATOR_FINISHED;
|
||||
|
|
Loading…
Reference in New Issue
The order of
initialze_cursor_info
and theninit_operation
is actually still needed. This fix would just introduce other errors on the following line:For now, this is probably best fixed by adding something like
gesture_data->operation = reinterpret_cast<gesture::Operation *>(MEM_cnew<TrimOperation>(__func__));
above
initialize_cursor_info
Hi, this will cause the memory leak. I would instead call
initialize_cursor_info
insideinit_operation
after operation is initialized.This allocation is already occurring in the existing code inside
init_operation
and is cleaned up when theunique_ptr
goes out of scope by theGestureData
destructor, but I agree that movinginitialize_cursor_info
intoinit_operation
is also a fine way of solving this.Pointer was created in _exec function, it'll be freed once we exit the _exec function. So the earlier allocated memory in
initialize_cursor_info
is not freed.BTW, I ended up moving allocation outside of init_operation 👀