Fix crash running constraint, modifier, fx from missing NULL check

None of these generic poll functions had NULL pointer checks,
since all operators that use these functions expect a valid constraint,
modifier .. etc. Add the NULL check to the poll function.

Ref D11126

Reviewed By: mont29, Severin
This commit is contained in:
Campbell Barton 2021-04-30 20:44:43 +10:00
parent d6b26b3fa0
commit f4d5a69cf8
Notes: blender-bot 2023-02-14 04:24:05 +01:00
Referenced by commit 99eca899c0, Revert "Fix crash running constraint, modifier, fx from missing NULL check"
4 changed files with 18 additions and 1 deletions

View File

@ -706,6 +706,11 @@ static bool edit_constraint_poll_generic(bContext *C,
return false;
}
if (!con) {
CTX_wm_operator_poll_msg_set(C, "Context missing active constraint");
return false;
}
if (!is_liboverride_allowed && BKE_constraint_is_nonlocal_in_liboverride(ob, con)) {
CTX_wm_operator_poll_msg_set(
C, "Cannot edit constraints coming from linked data in a library override");

View File

@ -443,6 +443,10 @@ static bool gpencil_edit_modifier_poll_generic(bContext *C,
return false;
}
if (!mod) {
return false;
}
if (!is_liboverride_allowed && BKE_gpencil_modifier_is_nonlocal_in_liboverride(ob, mod)) {
CTX_wm_operator_poll_msg_set(
C, "Cannot edit modifiers coming from linked data in a library override");

View File

@ -1051,6 +1051,10 @@ bool edit_modifier_poll_generic(bContext *C,
return false;
}
if (!mod) {
return false;
}
if (!is_liboverride_allowed && BKE_modifier_is_nonlocal_in_liboverride(ob, mod)) {
CTX_wm_operator_poll_msg_set(
C, "Cannot edit modifiers coming from linked data in a library override");

View File

@ -368,8 +368,12 @@ static bool edit_shaderfx_poll_generic(bContext *C, StructRNA *rna_type, int obt
return false;
}
if (!fx) {
return false;
}
if (ID_IS_OVERRIDE_LIBRARY(ob)) {
if ((fx == NULL) || (fx->flag & eShaderFxFlag_OverrideLibrary_Local) == 0) {
if ((fx->flag & eShaderFxFlag_OverrideLibrary_Local) == 0) {
CTX_wm_operator_poll_msg_set(C, "Cannot edit shaderfxs coming from library override");
return false;
}