Fix: Use error reports as indication of cancellation for some IO ops
During development of Collection Export, it was noticed that our various IO formats deal with errors in vastly different ways [1]. The crashes were all fixed but now the motivating scenario is as follows: If you setup a Collection Exporter for OBJ, STL, or PLY, and if it runs into an error during processing, the C++ operator will return "FINISHED" to the caller but the operator will also RPT_ERROR. This causes the caller, Collection Export, to indicate "success" to the user but the RPT_ERROR then causes a UI report that indicates failure. This PR chooses to use the presence of the RPT_ERROR as indication of "CANCELLED" operator status and should be safe enough to also apply to 4.2 LTS. This aligns with what Python does [2] and with what the new GSoC import nodes have chosen to do [3]. Though doing this on import isn't quite correct so this PR does not add that in to the base import operators. Alembic and USD are better behaved in this scenario already. However, they have their own quirks to follow-up afterwards. [1] https://projects.blender.org/blender/blender/issues/117881 [2] https://projects.blender.org/blender/blender/src/branch/main/source/blender/python/intern/bpy_capi_utils.cc#L25 [3] https://projects.blender.org/blender/blender/src/branch/main/source/blender/nodes/geometry/nodes/node_geo_import_obj.cc#L49 Pull Request: https://projects.blender.org/blender/blender/pulls/127525
This commit is contained in:
committed by
Jesse Yurkovich
parent
feaa7bbbcc
commit
9c36cfb4b8
@@ -111,8 +111,7 @@ static int wm_obj_export_exec(bContext *C, wmOperator *op)
|
||||
RNA_string_get(op->ptr, "collection", export_params.collection);
|
||||
|
||||
OBJ_export(C, &export_params);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
return BKE_reports_contain(op->reports, RPT_ERROR) ? OPERATOR_CANCELLED : OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static void ui_obj_export_settings(const bContext *C, uiLayout *layout, PointerRNA *ptr)
|
||||
|
||||
@@ -89,7 +89,7 @@ static int wm_ply_export_exec(bContext *C, wmOperator *op)
|
||||
|
||||
PLY_export(C, &export_params);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
return BKE_reports_contain(op->reports, RPT_ERROR) ? OPERATOR_CANCELLED : OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static void wm_ply_export_draw(bContext *C, wmOperator *op)
|
||||
|
||||
@@ -65,7 +65,7 @@ static int wm_stl_export_execute(bContext *C, wmOperator *op)
|
||||
|
||||
STL_export(C, &export_params);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
return BKE_reports_contain(op->reports, RPT_ERROR) ? OPERATOR_CANCELLED : OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static void wm_stl_export_draw(bContext *C, wmOperator *op)
|
||||
|
||||
Reference in New Issue
Block a user