Fix marker camera switch + undo crashes in edit-mode

Selecting markers and cameras could crash when in edit-mode.

Only support this in object mode as mode-switching as part of
activating cameras doesn't seem like a priority.

This has the same root cause as T84920.
This commit is contained in:
Campbell Barton 2021-01-22 10:56:53 +11:00
parent b9e07c1e0b
commit 99e5d5ba21
1 changed files with 10 additions and 0 deletions

View File

@ -1210,6 +1210,7 @@ static void select_marker_camera_switch(
{
#ifdef DURIAN_CAMERA_SWITCH
if (camera) {
BLI_assert(CTX_data_mode_enum(C) == CTX_MODE_OBJECT);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Base *base;
@ -1281,6 +1282,15 @@ static int ed_marker_select_exec(bContext *C, wmOperator *op)
bool camera = false;
#ifdef DURIAN_CAMERA_SWITCH
camera = RNA_boolean_get(op->ptr, "camera");
if (camera) {
/* Supporting mode switching from this operator doesn't seem so useful.
* So only allow setting the active camera in object-mode. */
if (CTX_data_mode_enum(C) != CTX_MODE_OBJECT) {
BKE_report(
op->reports, RPT_WARNING, "Selecting the camera is only supported in object mode");
camera = false;
}
}
#endif
int mval[2];
mval[0] = RNA_int_get(op->ptr, "mouse_x");