Fix #34315: memory leak cancelling move to layer operator, after change to make

it not execute immediately when opening the popup.
This commit is contained in:
Brecht Van Lommel
2013-02-19 13:37:48 +00:00
parent f784856906
commit e3b2df5806
5 changed files with 16 additions and 7 deletions

View File

@@ -361,7 +361,7 @@ void uiPupMenuInvoke(struct bContext *C, const char *idname); /* popup registere
* but allow using all button types and creating an own layout. */
typedef uiBlock * (*uiBlockCreateFunc)(struct bContext *C, struct ARegion *ar, void *arg1);
typedef void (*uiBlockCancelFunc)(void *arg1);
typedef void (*uiBlockCancelFunc)(struct bContext *C, void *arg1);
void uiPupBlock(struct bContext *C, uiBlockCreateFunc func, void *arg);
void uiPupBlockO(struct bContext *C, uiBlockCreateFunc func, void *arg, const char *opname, int opcontext);

View File

@@ -7159,7 +7159,7 @@ static int ui_handler_popup(bContext *C, const wmEvent *event, void *userdata)
WM_operator_name_call(C, temp.optype->idname, temp.opcontext, NULL);
}
else if (temp.cancel_func)
temp.cancel_func(temp.popup_arg);
temp.cancel_func(C, temp.popup_arg);
}
else {
/* re-enable tooltips */

View File

@@ -429,7 +429,7 @@ struct uiPopupBlockHandle {
int popup;
void (*popup_func)(struct bContext *C, void *arg, int event);
void (*cancel_func)(void *arg);
void (*cancel_func)(struct bContext *C, void *arg);
void *popup_arg;
struct wmTimer *scrolltimer;

View File

@@ -2574,7 +2574,7 @@ static void operator_cb(bContext *C, void *arg, int retval)
WM_operator_free(op);
}
static void confirm_cancel_operator(void *opv)
static void confirm_cancel_operator(bContext *UNUSED(C), void *opv)
{
WM_operator_free(opv);
}

View File

@@ -1243,7 +1243,7 @@ wmOperator *WM_operator_last_redo(const bContext *C)
return op;
}
static void wm_block_redo_cb(bContext *C, void *arg_op, int UNUSED(arg_event))
static void wm_block_redo_cb(bContext *C, void *arg_op, int arg_event)
{
wmOperator *op = arg_op;
@@ -1260,6 +1260,15 @@ static void wm_block_redo_cb(bContext *C, void *arg_op, int UNUSED(arg_event))
}
}
static void wm_block_redo_cancel_cb(bContext *C, void *arg_op)
{
wmOperator *op = arg_op;
/* if operator never got executed, free it */
if (op != WM_operator_last_redo(C))
WM_operator_free(op);
}
static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op)
{
wmOperator *op = arg_op;
@@ -1402,7 +1411,7 @@ static uiBlock *wm_operator_ui_create(bContext *C, ARegion *ar, void *userData)
return block;
}
static void wm_operator_ui_popup_cancel(void *userData)
static void wm_operator_ui_popup_cancel(struct bContext *UNUSED(C), void *userData)
{
wmOpPopUp *data = userData;
if (data->free_op && data->op) {
@@ -1452,7 +1461,7 @@ static int wm_operator_props_popup_ex(bContext *C, wmOperator *op, const int do_
if (!(U.uiflag & USER_GLOBALUNDO))
return WM_operator_props_dialog_popup(C, op, 15 * UI_UNIT_X, UI_UNIT_Y);
uiPupBlock(C, wm_block_create_redo, op);
uiPupBlockEx(C, wm_block_create_redo, NULL, wm_block_redo_cancel_cb, op);
if (do_call)
wm_block_redo_cb(C, op, 0);