Cleanup: replace int with wmOperatorStatus, consistent naming
- Manually check over all direct calls to operator callbacks ensuring the result isn't assigned to an int. - OPERATOR_RETVAL_CHECK() now fails unless a wmOperatorStatus is used. - Check the return values of direct calls to callbacks. - Remove invalid check for the return value of rna_operator_check_cb. - Use the variable name `retval` as it's most widely used. - Move the assignment of `retval` out of the `if` statement in sculpt/paint operators because it prevents assigning the result `const` variable.
This commit is contained in:
@@ -702,10 +702,10 @@ static wmOperatorStatus grease_pencil_primitive_invoke(bContext *C,
|
||||
wmOperator *op,
|
||||
const wmEvent *event)
|
||||
{
|
||||
wmOperatorStatus return_value = ed::greasepencil::grease_pencil_draw_operator_invoke(
|
||||
const wmOperatorStatus retval = ed::greasepencil::grease_pencil_draw_operator_invoke(
|
||||
C, op, false);
|
||||
if (return_value != OPERATOR_RUNNING_MODAL) {
|
||||
return return_value;
|
||||
if (retval != OPERATOR_RUNNING_MODAL) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* If in tools region, wait till we get to the main (3D-space)
|
||||
|
||||
@@ -797,15 +797,15 @@ void UI_popover_once_clear(uiPopover *pup);
|
||||
struct uiPieMenu;
|
||||
|
||||
wmOperatorStatus UI_pie_menu_invoke(bContext *C, const char *idname, const wmEvent *event);
|
||||
int UI_pie_menu_invoke_from_operator_enum(bContext *C,
|
||||
blender::StringRefNull title,
|
||||
blender::StringRefNull opname,
|
||||
blender::StringRefNull propname,
|
||||
const wmEvent *event);
|
||||
int UI_pie_menu_invoke_from_rna_enum(bContext *C,
|
||||
const char *title,
|
||||
const char *path,
|
||||
const wmEvent *event);
|
||||
wmOperatorStatus UI_pie_menu_invoke_from_operator_enum(bContext *C,
|
||||
blender::StringRefNull title,
|
||||
blender::StringRefNull opname,
|
||||
blender::StringRefNull propname,
|
||||
const wmEvent *event);
|
||||
wmOperatorStatus UI_pie_menu_invoke_from_rna_enum(bContext *C,
|
||||
const char *title,
|
||||
const char *path,
|
||||
const wmEvent *event);
|
||||
|
||||
uiPieMenu *UI_pie_menu_begin(bContext *C, const char *title, int icon, const wmEvent *event)
|
||||
ATTR_NONNULL();
|
||||
|
||||
@@ -220,11 +220,11 @@ wmOperatorStatus UI_pie_menu_invoke(bContext *C, const char *idname, const wmEve
|
||||
return OPERATOR_INTERFACE;
|
||||
}
|
||||
|
||||
int UI_pie_menu_invoke_from_operator_enum(bContext *C,
|
||||
const StringRefNull title,
|
||||
const StringRefNull opname,
|
||||
const StringRefNull propname,
|
||||
const wmEvent *event)
|
||||
wmOperatorStatus UI_pie_menu_invoke_from_operator_enum(bContext *C,
|
||||
const StringRefNull title,
|
||||
const StringRefNull opname,
|
||||
const StringRefNull propname,
|
||||
const wmEvent *event)
|
||||
{
|
||||
uiPieMenu *pie;
|
||||
uiLayout *layout;
|
||||
@@ -240,10 +240,10 @@ int UI_pie_menu_invoke_from_operator_enum(bContext *C,
|
||||
return OPERATOR_INTERFACE;
|
||||
}
|
||||
|
||||
int UI_pie_menu_invoke_from_rna_enum(bContext *C,
|
||||
const char *title,
|
||||
const char *path,
|
||||
const wmEvent *event)
|
||||
wmOperatorStatus UI_pie_menu_invoke_from_rna_enum(bContext *C,
|
||||
const char *title,
|
||||
const char *path,
|
||||
const wmEvent *event)
|
||||
{
|
||||
PointerRNA r_ptr;
|
||||
PropertyRNA *r_prop;
|
||||
|
||||
@@ -755,10 +755,10 @@ static void COLLECTION_OT_export_all(wmOperatorType *ot)
|
||||
ot->flag = 0;
|
||||
}
|
||||
|
||||
static int collection_export_recursive(bContext *C,
|
||||
wmOperator *op,
|
||||
LayerCollection *layer_collection,
|
||||
CollectionExportStats &stats)
|
||||
static wmOperatorStatus collection_export_recursive(bContext *C,
|
||||
wmOperator *op,
|
||||
LayerCollection *layer_collection,
|
||||
CollectionExportStats &stats)
|
||||
{
|
||||
/* Skip collections which have been Excluded in the View Layer. */
|
||||
if (layer_collection->flag & LAYER_COLLECTION_EXCLUDE) {
|
||||
|
||||
@@ -228,8 +228,10 @@ static wmOperatorStatus sculpt_curves_stroke_invoke(bContext *C,
|
||||
event->type);
|
||||
op->customdata = op_data;
|
||||
|
||||
int return_value = op->type->modal(C, op, event);
|
||||
if (return_value == OPERATOR_FINISHED) {
|
||||
const wmOperatorStatus retval = op->type->modal(C, op, event);
|
||||
OPERATOR_RETVAL_CHECK(retval);
|
||||
|
||||
if (retval == OPERATOR_FINISHED) {
|
||||
if (op->customdata != nullptr) {
|
||||
paint_stroke_free(C, op, op_data->stroke);
|
||||
MEM_delete(op_data);
|
||||
@@ -247,12 +249,12 @@ static wmOperatorStatus sculpt_curves_stroke_modal(bContext *C,
|
||||
{
|
||||
SculptCurvesBrushStrokeData *op_data = static_cast<SculptCurvesBrushStrokeData *>(
|
||||
op->customdata);
|
||||
wmOperatorStatus return_value = paint_stroke_modal(C, op, event, &op_data->stroke);
|
||||
if (ELEM(return_value, OPERATOR_FINISHED, OPERATOR_CANCELLED)) {
|
||||
wmOperatorStatus retval = paint_stroke_modal(C, op, event, &op_data->stroke);
|
||||
if (ELEM(retval, OPERATOR_FINISHED, OPERATOR_CANCELLED)) {
|
||||
MEM_delete(op_data);
|
||||
op->customdata = nullptr;
|
||||
}
|
||||
return return_value;
|
||||
return retval;
|
||||
}
|
||||
|
||||
static void sculpt_curves_stroke_cancel(bContext *C, wmOperator *op)
|
||||
|
||||
@@ -268,10 +268,10 @@ static wmOperatorStatus grease_pencil_brush_stroke_invoke(bContext *C,
|
||||
}
|
||||
return false;
|
||||
}();
|
||||
wmOperatorStatus return_value = ed::greasepencil::grease_pencil_draw_operator_invoke(
|
||||
wmOperatorStatus retval = ed::greasepencil::grease_pencil_draw_operator_invoke(
|
||||
C, op, use_duplicate_previous_key);
|
||||
if (return_value != OPERATOR_RUNNING_MODAL) {
|
||||
return return_value;
|
||||
if (retval != OPERATOR_RUNNING_MODAL) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
op->customdata = paint_stroke_new(C,
|
||||
@@ -283,8 +283,10 @@ static wmOperatorStatus grease_pencil_brush_stroke_invoke(bContext *C,
|
||||
stroke_done,
|
||||
event->type);
|
||||
|
||||
return_value = op->type->modal(C, op, event);
|
||||
if (return_value == OPERATOR_FINISHED) {
|
||||
retval = op->type->modal(C, op, event);
|
||||
OPERATOR_RETVAL_CHECK(retval);
|
||||
|
||||
if (retval == OPERATOR_FINISHED) {
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@@ -393,8 +395,10 @@ static wmOperatorStatus grease_pencil_sculpt_paint_invoke(bContext *C,
|
||||
stroke_done,
|
||||
event->type);
|
||||
|
||||
const int return_value = op->type->modal(C, op, event);
|
||||
if (return_value == OPERATOR_FINISHED) {
|
||||
const wmOperatorStatus retval = op->type->modal(C, op, event);
|
||||
OPERATOR_RETVAL_CHECK(retval);
|
||||
|
||||
if (retval == OPERATOR_FINISHED) {
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@@ -486,8 +490,10 @@ static wmOperatorStatus grease_pencil_weight_brush_stroke_invoke(bContext *C,
|
||||
stroke_done,
|
||||
event->type);
|
||||
|
||||
const int return_value = op->type->modal(C, op, event);
|
||||
if (return_value == OPERATOR_FINISHED) {
|
||||
const wmOperatorStatus retval = op->type->modal(C, op, event);
|
||||
OPERATOR_RETVAL_CHECK(retval);
|
||||
|
||||
if (retval == OPERATOR_FINISHED) {
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@@ -592,8 +598,10 @@ static wmOperatorStatus grease_pencil_vertex_brush_stroke_invoke(bContext *C,
|
||||
stroke_done,
|
||||
event->type);
|
||||
|
||||
const int return_value = op->type->modal(C, op, event);
|
||||
if (return_value == OPERATOR_FINISHED) {
|
||||
const wmOperatorStatus retval = op->type->modal(C, op, event);
|
||||
OPERATOR_RETVAL_CHECK(retval);
|
||||
|
||||
if (retval == OPERATOR_FINISHED) {
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
|
||||
@@ -453,8 +453,6 @@ static bool paint_stroke_test_start(bContext *C, wmOperator *op, const float mou
|
||||
|
||||
static wmOperatorStatus paint_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
int retval;
|
||||
|
||||
op->customdata = paint_stroke_new(C,
|
||||
op,
|
||||
nullptr,
|
||||
@@ -464,14 +462,16 @@ static wmOperatorStatus paint_invoke(bContext *C, wmOperator *op, const wmEvent
|
||||
paint_stroke_done,
|
||||
event->type);
|
||||
|
||||
if ((retval = op->type->modal(C, op, event)) == OPERATOR_FINISHED) {
|
||||
const wmOperatorStatus retval = op->type->modal(C, op, event);
|
||||
OPERATOR_RETVAL_CHECK(retval);
|
||||
|
||||
if (retval == OPERATOR_FINISHED) {
|
||||
paint_stroke_free(C, op, static_cast<PaintStroke *>(op->customdata));
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
/* add modal handler */
|
||||
WM_event_add_modal_handler(C, op);
|
||||
|
||||
OPERATOR_RETVAL_CHECK(retval);
|
||||
BLI_assert(retval == OPERATOR_RUNNING_MODAL);
|
||||
|
||||
return OPERATOR_RUNNING_MODAL;
|
||||
|
||||
@@ -2036,8 +2036,6 @@ static void vpaint_stroke_done(const bContext *C, PaintStroke *stroke)
|
||||
|
||||
static wmOperatorStatus vpaint_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
int retval;
|
||||
|
||||
op->customdata = paint_stroke_new(C,
|
||||
op,
|
||||
SCULPT_stroke_get_location,
|
||||
@@ -2052,14 +2050,16 @@ static wmOperatorStatus vpaint_invoke(bContext *C, wmOperator *op, const wmEvent
|
||||
|
||||
undo::push_begin_ex(scene, ob, "Vertex Paint");
|
||||
|
||||
if ((retval = op->type->modal(C, op, event)) == OPERATOR_FINISHED) {
|
||||
const wmOperatorStatus retval = op->type->modal(C, op, event);
|
||||
OPERATOR_RETVAL_CHECK(retval);
|
||||
|
||||
if (retval == OPERATOR_FINISHED) {
|
||||
paint_stroke_free(C, op, (PaintStroke *)op->customdata);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
WM_event_add_modal_handler(C, op);
|
||||
|
||||
OPERATOR_RETVAL_CHECK(retval);
|
||||
BLI_assert(retval == OPERATOR_RUNNING_MODAL);
|
||||
|
||||
return OPERATOR_RUNNING_MODAL;
|
||||
|
||||
@@ -1924,8 +1924,6 @@ static void wpaint_stroke_done(const bContext *C, PaintStroke * /*stroke*/)
|
||||
|
||||
static wmOperatorStatus wpaint_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
int retval;
|
||||
|
||||
op->customdata = paint_stroke_new(C,
|
||||
op,
|
||||
SCULPT_stroke_get_location,
|
||||
@@ -1935,13 +1933,15 @@ static wmOperatorStatus wpaint_invoke(bContext *C, wmOperator *op, const wmEvent
|
||||
wpaint_stroke_done,
|
||||
event->type);
|
||||
|
||||
if ((retval = op->type->modal(C, op, event)) == OPERATOR_FINISHED) {
|
||||
const wmOperatorStatus retval = op->type->modal(C, op, event);
|
||||
OPERATOR_RETVAL_CHECK(retval);
|
||||
|
||||
if (retval == OPERATOR_FINISHED) {
|
||||
paint_stroke_free(C, op, (PaintStroke *)op->customdata);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
WM_event_add_modal_handler(C, op);
|
||||
|
||||
OPERATOR_RETVAL_CHECK(retval);
|
||||
BLI_assert(retval == OPERATOR_RUNNING_MODAL);
|
||||
|
||||
return OPERATOR_RUNNING_MODAL;
|
||||
|
||||
@@ -5747,7 +5747,6 @@ static wmOperatorStatus sculpt_brush_stroke_invoke(bContext *C,
|
||||
{
|
||||
PaintStroke *stroke;
|
||||
int ignore_background_click;
|
||||
wmOperatorStatus retval;
|
||||
Object &ob = *CTX_data_active_object(C);
|
||||
Scene &scene = *CTX_data_scene(C);
|
||||
const View3D *v3d = CTX_wm_view3d(C);
|
||||
@@ -5809,7 +5808,9 @@ static wmOperatorStatus sculpt_brush_stroke_invoke(bContext *C,
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
|
||||
retval = op->type->modal(C, op, event);
|
||||
const wmOperatorStatus retval = op->type->modal(C, op, event);
|
||||
OPERATOR_RETVAL_CHECK(retval);
|
||||
|
||||
if (ELEM(retval, OPERATOR_FINISHED, OPERATOR_CANCELLED)) {
|
||||
paint_stroke_free(C, op, static_cast<PaintStroke *>(op->customdata));
|
||||
return retval;
|
||||
@@ -5817,7 +5818,6 @@ static wmOperatorStatus sculpt_brush_stroke_invoke(bContext *C,
|
||||
/* Add modal handler. */
|
||||
WM_event_add_modal_handler(C, op);
|
||||
|
||||
OPERATOR_RETVAL_CHECK(retval);
|
||||
BLI_assert(retval == OPERATOR_RUNNING_MODAL);
|
||||
|
||||
return OPERATOR_RUNNING_MODAL;
|
||||
|
||||
@@ -658,8 +658,6 @@ bool ED_undo_operator_repeat(bContext *C, wmOperator *op)
|
||||
* NOTE: WM_operator_check_ui_enabled() jobs test _must_ stay in sync with this. */
|
||||
(WM_jobs_test(wm, scene, WM_JOB_TYPE_ANY) == 0))
|
||||
{
|
||||
int retval;
|
||||
|
||||
if (G.debug & G_DEBUG) {
|
||||
printf("redo_cb: operator redo %s\n", op->type->name);
|
||||
}
|
||||
@@ -678,7 +676,7 @@ bool ED_undo_operator_repeat(bContext *C, wmOperator *op)
|
||||
}
|
||||
}
|
||||
|
||||
retval = WM_operator_repeat(C, op);
|
||||
const wmOperatorStatus retval = WM_operator_repeat(C, op);
|
||||
if ((retval & OPERATOR_FINISHED) == 0) {
|
||||
if (G.debug & G_DEBUG) {
|
||||
printf("redo_cb: operator redo failed: %s, return %d\n", op->type->name, retval);
|
||||
|
||||
@@ -33,7 +33,11 @@ enum wmOperatorStatus {
|
||||
|
||||
/* sanity checks for debug mode only */
|
||||
#define OPERATOR_RETVAL_CHECK(ret) \
|
||||
(void)ret, BLI_assert(ret != 0 && (ret & OPERATOR_FLAGS_ALL) == ret)
|
||||
{ \
|
||||
CHECK_TYPE(ret, wmOperatorStatus); \
|
||||
BLI_assert(ret != 0 && (ret & OPERATOR_FLAGS_ALL) == ret); \
|
||||
} \
|
||||
((void)0)
|
||||
|
||||
ENUM_OPERATORS(wmOperatorStatus, OPERATOR_INTERFACE);
|
||||
|
||||
|
||||
@@ -1444,7 +1444,6 @@ static wmOperatorStatus rna_operator_exec_cb(bContext *C, wmOperator *op)
|
||||
ParameterList list;
|
||||
FunctionRNA *func;
|
||||
void *ret;
|
||||
int result;
|
||||
|
||||
ID *owner_id = (op->ptr) ? op->ptr->owner_id : nullptr;
|
||||
PointerRNA opr = RNA_pointer_create_discrete(owner_id, op->type->rna_ext.srna, op);
|
||||
@@ -1455,7 +1454,7 @@ static wmOperatorStatus rna_operator_exec_cb(bContext *C, wmOperator *op)
|
||||
const bool has_error = op->type->rna_ext.call(C, &opr, func, &list) == -1;
|
||||
|
||||
RNA_parameter_get_lookup(&list, "result", &ret);
|
||||
result = *(int *)ret;
|
||||
const wmOperatorStatus result = wmOperatorStatus(*(int *)ret);
|
||||
|
||||
RNA_parameter_list_free(&list);
|
||||
|
||||
@@ -1465,7 +1464,7 @@ static wmOperatorStatus rna_operator_exec_cb(bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
OPERATOR_RETVAL_CHECK(result);
|
||||
return wmOperatorStatus(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* same as execute() but no return value */
|
||||
@@ -1491,8 +1490,7 @@ static bool rna_operator_check_cb(bContext *C, wmOperator *op)
|
||||
|
||||
RNA_parameter_list_free(&list);
|
||||
|
||||
OPERATOR_RETVAL_CHECK(result);
|
||||
return wmOperatorStatus(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
static wmOperatorStatus rna_operator_invoke_cb(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
@@ -1502,7 +1500,6 @@ static wmOperatorStatus rna_operator_invoke_cb(bContext *C, wmOperator *op, cons
|
||||
ParameterList list;
|
||||
FunctionRNA *func;
|
||||
void *ret;
|
||||
int result;
|
||||
|
||||
ID *owner_id = (op->ptr) ? op->ptr->owner_id : nullptr;
|
||||
PointerRNA opr = RNA_pointer_create_discrete(owner_id, op->type->rna_ext.srna, op);
|
||||
@@ -1514,7 +1511,7 @@ static wmOperatorStatus rna_operator_invoke_cb(bContext *C, wmOperator *op, cons
|
||||
const bool has_error = op->type->rna_ext.call(C, &opr, func, &list) == -1;
|
||||
|
||||
RNA_parameter_get_lookup(&list, "result", &ret);
|
||||
result = *(int *)ret;
|
||||
wmOperatorStatus retval = wmOperatorStatus(*(int *)ret);
|
||||
|
||||
RNA_parameter_list_free(&list);
|
||||
|
||||
@@ -1523,8 +1520,8 @@ static wmOperatorStatus rna_operator_invoke_cb(bContext *C, wmOperator *op, cons
|
||||
WM_event_remove_modal_handler_all(op, false);
|
||||
}
|
||||
|
||||
OPERATOR_RETVAL_CHECK(result);
|
||||
return wmOperatorStatus(result);
|
||||
OPERATOR_RETVAL_CHECK(retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* same as invoke */
|
||||
@@ -1535,7 +1532,6 @@ static wmOperatorStatus rna_operator_modal_cb(bContext *C, wmOperator *op, const
|
||||
ParameterList list;
|
||||
FunctionRNA *func;
|
||||
void *ret;
|
||||
int result;
|
||||
|
||||
ID *owner_id = (op->ptr) ? op->ptr->owner_id : nullptr;
|
||||
PointerRNA opr = RNA_pointer_create_discrete(owner_id, op->type->rna_ext.srna, op);
|
||||
@@ -1547,12 +1543,12 @@ static wmOperatorStatus rna_operator_modal_cb(bContext *C, wmOperator *op, const
|
||||
op->type->rna_ext.call(C, &opr, func, &list);
|
||||
|
||||
RNA_parameter_get_lookup(&list, "result", &ret);
|
||||
result = *(int *)ret;
|
||||
wmOperatorStatus retval = wmOperatorStatus(*(int *)ret);
|
||||
|
||||
RNA_parameter_list_free(&list);
|
||||
|
||||
OPERATOR_RETVAL_CHECK(result);
|
||||
return wmOperatorStatus(result);
|
||||
OPERATOR_RETVAL_CHECK(retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
static void rna_operator_draw_cb(bContext *C, wmOperator *op)
|
||||
|
||||
@@ -131,12 +131,12 @@ static wmOperatorStatus rna_gizmo_modal_cb(bContext *C,
|
||||
|
||||
void *ret;
|
||||
RNA_parameter_get_lookup(&list, "result", &ret);
|
||||
int ret_enum = *(int *)ret;
|
||||
wmOperatorStatus retval = wmOperatorStatus(*(int *)ret);
|
||||
|
||||
RNA_parameter_list_free(&list);
|
||||
|
||||
OPERATOR_RETVAL_CHECK(ret_enum);
|
||||
return wmOperatorStatus(ret_enum);
|
||||
OPERATOR_RETVAL_CHECK(retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
static void rna_gizmo_setup_cb(wmGizmo *gz)
|
||||
@@ -169,12 +169,12 @@ static wmOperatorStatus rna_gizmo_invoke_cb(bContext *C, wmGizmo *gz, const wmEv
|
||||
|
||||
void *ret;
|
||||
RNA_parameter_get_lookup(&list, "result", &ret);
|
||||
int ret_enum = *(int *)ret;
|
||||
const wmOperatorStatus retval = wmOperatorStatus(*(int *)ret);
|
||||
|
||||
RNA_parameter_list_free(&list);
|
||||
|
||||
OPERATOR_RETVAL_CHECK(ret_enum);
|
||||
return wmOperatorStatus(ret_enum);
|
||||
OPERATOR_RETVAL_CHECK(retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
static void rna_gizmo_exit_cb(bContext *C, wmGizmo *gz, bool cancel)
|
||||
|
||||
@@ -132,7 +132,7 @@ static PyObject *pyop_call(PyObject * /*self*/, PyObject *args)
|
||||
wmOperatorType *ot;
|
||||
int error_val = 0;
|
||||
PointerRNA ptr;
|
||||
wmOperatorStatus operator_ret = OPERATOR_CANCELLED;
|
||||
wmOperatorStatus retval = OPERATOR_CANCELLED;
|
||||
|
||||
const char *opname;
|
||||
const char *context_str = nullptr;
|
||||
@@ -243,7 +243,7 @@ static PyObject *pyop_call(PyObject * /*self*/, PyObject *args)
|
||||
PyThreadState *ts = PyEval_SaveThread();
|
||||
#endif
|
||||
|
||||
operator_ret = WM_operator_call_py(C, ot, context, &ptr, reports, is_undo);
|
||||
retval = WM_operator_call_py(C, ot, context, &ptr, reports, is_undo);
|
||||
|
||||
#ifdef BPY_RELEASE_GIL
|
||||
/* regain GIL */
|
||||
@@ -300,8 +300,8 @@ static PyObject *pyop_call(PyObject * /*self*/, PyObject *args)
|
||||
* function corrects bpy.data (internal Main pointer) */
|
||||
BPY_modules_update();
|
||||
|
||||
/* return operator_ret as a bpy enum */
|
||||
return pyrna_enum_bitfield_as_set(rna_enum_operator_return_items, int(operator_ret));
|
||||
/* Return `retval` flag as a set. */
|
||||
return pyrna_enum_bitfield_as_set(rna_enum_operator_return_items, int(retval));
|
||||
}
|
||||
|
||||
static PyObject *pyop_as_string(PyObject * /*self*/, PyObject *args)
|
||||
|
||||
@@ -1067,7 +1067,9 @@ void wm_gizmomap_modal_set(
|
||||
}
|
||||
|
||||
if (gz->type->invoke && (gz->type->modal || gz->custom_modal)) {
|
||||
const int retval = gz->type->invoke(C, gz, event);
|
||||
const wmOperatorStatus retval = gz->type->invoke(C, gz, event);
|
||||
OPERATOR_RETVAL_CHECK(retval);
|
||||
|
||||
if ((retval & OPERATOR_RUNNING_MODAL) == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -1090,7 +1092,9 @@ void wm_gizmomap_modal_set(
|
||||
|
||||
wmGizmoOpElem *gzop = WM_gizmo_operator_get(gz, gz->highlight_part);
|
||||
if (gzop && gzop->type) {
|
||||
const int retval = WM_gizmo_operator_invoke(C, gz, gzop, event);
|
||||
const wmOperatorStatus retval = WM_gizmo_operator_invoke(C, gz, gzop, event);
|
||||
OPERATOR_RETVAL_CHECK(retval);
|
||||
|
||||
if ((retval & OPERATOR_RUNNING_MODAL) == 0) {
|
||||
wm_gizmomap_modal_set(gzmap, C, gz, event, false);
|
||||
}
|
||||
|
||||
@@ -1152,7 +1152,7 @@ void WM_operator_region_active_win_set(bContext *C)
|
||||
*/
|
||||
static void wm_operator_reports(bContext *C,
|
||||
wmOperator *op,
|
||||
const int retval,
|
||||
const wmOperatorStatus retval,
|
||||
const bool caller_owns_reports)
|
||||
{
|
||||
if (G.background == 0 && caller_owns_reports == false) { /* Popup. */
|
||||
@@ -2914,13 +2914,12 @@ static eHandlerActionFlag wm_handler_fileselect_do(bContext *C,
|
||||
/* Needed for #UI_popup_menu_reports. */
|
||||
|
||||
if (val == EVT_FILESELECT_EXEC) {
|
||||
int retval;
|
||||
|
||||
if (handler->op->type->flag & OPTYPE_UNDO) {
|
||||
wm->op_undo_depth++;
|
||||
}
|
||||
|
||||
retval = handler->op->type->exec(C, handler->op);
|
||||
const wmOperatorStatus retval = handler->op->type->exec(C, handler->op);
|
||||
OPERATOR_RETVAL_CHECK(retval);
|
||||
|
||||
/* XXX check this carefully, `CTX_wm_manager(C) == wm` is a bit hackish. */
|
||||
if (handler->op->type->flag & OPTYPE_UNDO && CTX_wm_manager(C) == wm) {
|
||||
@@ -3471,7 +3470,7 @@ static eHandlerActionFlag wm_handlers_do_intern(bContext *C,
|
||||
event->customdata = &single_lb;
|
||||
|
||||
const wmOperatorCallContext opcontext = wm_drop_operator_context_get(drop);
|
||||
int op_retval =
|
||||
const wmOperatorStatus op_retval =
|
||||
drop->ot ? wm_operator_call_internal(
|
||||
C, drop->ot, drop->ptr, nullptr, opcontext, false, event) :
|
||||
OPERATOR_CANCELLED;
|
||||
|
||||
@@ -152,8 +152,6 @@ static bool gesture_box_apply(bContext *C, wmOperator *op)
|
||||
{
|
||||
wmGesture *gesture = static_cast<wmGesture *>(op->customdata);
|
||||
|
||||
int retval;
|
||||
|
||||
if (!gesture_box_apply_rect(op)) {
|
||||
return false;
|
||||
}
|
||||
@@ -162,7 +160,7 @@ static bool gesture_box_apply(bContext *C, wmOperator *op)
|
||||
gesture_modal_state_to_operator(op, gesture->modal_state);
|
||||
}
|
||||
|
||||
retval = op->type->exec(C, op);
|
||||
const wmOperatorStatus retval = op->type->exec(C, op);
|
||||
OPERATOR_RETVAL_CHECK(retval);
|
||||
|
||||
return (retval & OPERATOR_FINISHED) ? true : false;
|
||||
@@ -344,8 +342,7 @@ static void gesture_circle_apply(bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
if (op->type->exec) {
|
||||
int retval;
|
||||
retval = op->type->exec(C, op);
|
||||
const wmOperatorStatus retval = op->type->exec(C, op);
|
||||
OPERATOR_RETVAL_CHECK(retval);
|
||||
}
|
||||
}
|
||||
@@ -990,7 +987,7 @@ static bool gesture_straightline_apply(bContext *C, wmOperator *op)
|
||||
RNA_boolean_set(op->ptr, "flip", gesture->use_flip);
|
||||
|
||||
if (op->type->exec) {
|
||||
int retval = op->type->exec(C, op);
|
||||
const wmOperatorStatus retval = op->type->exec(C, op);
|
||||
OPERATOR_RETVAL_CHECK(retval);
|
||||
}
|
||||
|
||||
|
||||
@@ -310,7 +310,7 @@ void WM_operatortype_idname_visit_for_search(
|
||||
* \{ */
|
||||
|
||||
struct MacroData {
|
||||
int retval;
|
||||
wmOperatorStatus retval;
|
||||
};
|
||||
|
||||
static void wm_macro_start(wmOperator *op)
|
||||
|
||||
@@ -265,7 +265,7 @@ static wmOperatorStatus op_generic_value_modal(bContext *C, wmOperator *op, cons
|
||||
}
|
||||
|
||||
wm->op_undo_depth++;
|
||||
int retval = op->type->exec(C, op);
|
||||
const wmOperatorStatus retval = op->type->exec(C, op);
|
||||
OPERATOR_RETVAL_CHECK(retval);
|
||||
wm->op_undo_depth--;
|
||||
|
||||
|
||||
@@ -985,31 +985,32 @@ wmOperatorStatus WM_generic_select_modal(bContext *C, wmOperator *op, const wmEv
|
||||
if (event->val == KM_PRESS) {
|
||||
RNA_property_boolean_set(op->ptr, wait_to_deselect_prop, true);
|
||||
|
||||
wmOperatorStatus ret_value = op->type->exec(C, op);
|
||||
OPERATOR_RETVAL_CHECK(ret_value);
|
||||
wmOperatorStatus retval = op->type->exec(C, op);
|
||||
OPERATOR_RETVAL_CHECK(retval);
|
||||
|
||||
op->customdata = POINTER_FROM_INT(int(event->type));
|
||||
if (ret_value & OPERATOR_RUNNING_MODAL) {
|
||||
if (retval & OPERATOR_RUNNING_MODAL) {
|
||||
WM_event_add_modal_handler(C, op);
|
||||
}
|
||||
return ret_value | OPERATOR_PASS_THROUGH;
|
||||
return retval | OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
/* If we are in init phase, and cannot validate init of modal operations,
|
||||
* just fall back to basic exec.
|
||||
*/
|
||||
RNA_property_boolean_set(op->ptr, wait_to_deselect_prop, false);
|
||||
|
||||
wmOperatorStatus ret_value = op->type->exec(C, op);
|
||||
OPERATOR_RETVAL_CHECK(ret_value);
|
||||
wmOperatorStatus retval = op->type->exec(C, op);
|
||||
OPERATOR_RETVAL_CHECK(retval);
|
||||
|
||||
return ret_value | OPERATOR_PASS_THROUGH;
|
||||
return retval | OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
if (event->type == init_event_type && event->val == KM_RELEASE) {
|
||||
RNA_property_boolean_set(op->ptr, wait_to_deselect_prop, false);
|
||||
|
||||
wmOperatorStatus ret_value = op->type->exec(C, op);
|
||||
OPERATOR_RETVAL_CHECK(ret_value);
|
||||
wmOperatorStatus retval = op->type->exec(C, op);
|
||||
OPERATOR_RETVAL_CHECK(retval);
|
||||
|
||||
return ret_value | OPERATOR_PASS_THROUGH;
|
||||
return retval | OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
if (ISMOUSE_MOTION(event->type)) {
|
||||
const int drag_delta[2] = {
|
||||
@@ -1042,7 +1043,9 @@ wmOperatorStatus WM_generic_select_invoke(bContext *C, wmOperator *op, const wmE
|
||||
|
||||
op->customdata = POINTER_FROM_INT(0);
|
||||
|
||||
return op->type->modal(C, op, event);
|
||||
wmOperatorStatus retval = op->type->modal(C, op, event);
|
||||
OPERATOR_RETVAL_CHECK(retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
void WM_operator_view3d_unit_defaults(bContext *C, wmOperator *op)
|
||||
|
||||
@@ -1307,9 +1307,10 @@ static wmOperatorStatus wm_xr_navigation_teleport_invoke(bContext *C,
|
||||
|
||||
wm_xr_raycast_init(op);
|
||||
|
||||
wmOperatorStatus retval = op->type->modal(C, op, event);
|
||||
const wmOperatorStatus retval = op->type->modal(C, op, event);
|
||||
OPERATOR_RETVAL_CHECK(retval);
|
||||
|
||||
if ((retval & OPERATOR_RUNNING_MODAL) != 0) {
|
||||
if (retval & OPERATOR_RUNNING_MODAL) {
|
||||
WM_event_add_modal_handler(C, op);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user