Fix crashes from various missing checks in operator poll functions
Issues exposed by 'bl_run_operators.py' utility.
This commit is contained in:
parent
52cff88f72
commit
33da997193
|
@ -235,6 +235,9 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *r_first, float *
|
|||
static bool ED_operator_markers_region_active(bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (sa->spacetype) {
|
||||
case SPACE_ACTION: {
|
||||
|
|
|
@ -1755,7 +1755,7 @@ void GPENCIL_OT_convert(wmOperatorType *ot)
|
|||
static bool image_to_gpencil_poll(bContext *C)
|
||||
{
|
||||
SpaceLink *sl = CTX_wm_space_data(C);
|
||||
if (sl->spacetype == SPACE_IMAGE) {
|
||||
if ((sl != NULL) && (sl->spacetype == SPACE_IMAGE)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1379,7 +1379,8 @@ void GPENCIL_OT_copy(wmOperatorType *ot)
|
|||
|
||||
static bool gp_strokes_paste_poll(bContext *C)
|
||||
{
|
||||
if (CTX_wm_area(C)->spacetype != SPACE_VIEW3D) {
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (!((sa != NULL) && (sa->spacetype == SPACE_VIEW3D))) {
|
||||
return false;
|
||||
}
|
||||
/* 1) Must have GP datablock to paste to
|
||||
|
|
|
@ -1192,7 +1192,7 @@ static bool modifier_apply_poll(bContext *C)
|
|||
Object *ob = (ptr.owner_id != NULL) ? (Object *)ptr.owner_id : ED_object_active_context(C);
|
||||
ModifierData *md = ptr.data; /* May be NULL. */
|
||||
|
||||
if (ID_REAL_USERS(ob->data) > 1) {
|
||||
if ((ob->data != NULL) && ID_REAL_USERS(ob->data) > 1) {
|
||||
CTX_wm_operator_poll_msg_set(C, "Modifiers cannot be applied to multi-user data");
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -3142,7 +3142,7 @@ static void SCREEN_OT_screen_set(wmOperatorType *ot)
|
|||
ot->poll = ED_operator_screenactive;
|
||||
|
||||
/* rna */
|
||||
RNA_def_int(ot->srna, "delta", 0, INT_MIN, INT_MAX, "Delta", "", INT_MIN, INT_MAX);
|
||||
RNA_def_int(ot->srna, "delta", 1, -1, 1, "Delta", "", -1, 1);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
#include "BKE_colortools.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_customdata.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_idprop.h"
|
||||
#include "BKE_image.h"
|
||||
#include "BKE_lib_id.h"
|
||||
|
@ -6201,11 +6202,12 @@ void PAINT_OT_project_image(wmOperatorType *ot)
|
|||
|
||||
static bool texture_paint_image_from_view_poll(bContext *C)
|
||||
{
|
||||
if (BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_VIEW3D, 0) == NULL) {
|
||||
bScreen *screen = CTX_wm_screen(C);
|
||||
if (!(screen && BKE_screen_find_big_area(screen, SPACE_VIEW3D, 0))) {
|
||||
CTX_wm_operator_poll_msg_set(C, "No 3D viewport found to create image from");
|
||||
return false;
|
||||
}
|
||||
if (!GPU_is_initialized()) {
|
||||
if (G.background || !GPU_is_initialized()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -6754,7 +6756,7 @@ void PAINT_OT_add_texture_paint_slot(wmOperatorType *ot)
|
|||
/* api callbacks */
|
||||
ot->invoke = texture_paint_add_texture_paint_slot_invoke;
|
||||
ot->exec = texture_paint_add_texture_paint_slot_exec;
|
||||
ot->poll = ED_operator_object_active;
|
||||
ot->poll = ED_operator_object_active_editable_mesh;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_UNDO;
|
||||
|
|
|
@ -303,7 +303,7 @@ static void PALETTE_OT_color_delete(wmOperatorType *ot)
|
|||
static bool palette_extract_img_poll(bContext *C)
|
||||
{
|
||||
SpaceLink *sl = CTX_wm_space_data(C);
|
||||
if (sl->spacetype == SPACE_IMAGE) {
|
||||
if ((sl != NULL) && (sl->spacetype == SPACE_IMAGE)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1031,7 +1031,7 @@ static void TRANSFORM_OT_bbone_resize(struct wmOperatorType *ot)
|
|||
ot->exec = transform_exec;
|
||||
ot->modal = transform_modal;
|
||||
ot->cancel = transform_cancel;
|
||||
ot->poll = ED_operator_screenactive;
|
||||
ot->poll = ED_operator_editarmature;
|
||||
ot->poll_property = transform_poll_property;
|
||||
|
||||
RNA_def_float_translation(
|
||||
|
|
Loading…
Reference in New Issue