Fix (unreported) bad handling of detection of what to override from 3DView in some cases.

Having a directly linked object does not always mean it should be
considered as really overridable...
This commit is contained in:
Bastien Montagne 2020-07-21 11:58:20 +02:00
parent b277a75a3b
commit ece6d8b25a
1 changed files with 15 additions and 2 deletions

View File

@ -2242,9 +2242,22 @@ void OBJECT_OT_make_local(wmOperatorType *ot)
/** \name Make Library Override Operator
* \{ */
static bool make_override_library_ovject_overridable_check(Main *bmain, Object *object)
{
/* An object is actually overridable only if it is in at least one local collections...
* Unfortunatly 'direct link' flag is not enough here. */
LISTBASE_FOREACH (Collection *, collection, &bmain->collections) {
if (!ID_IS_LINKED(collection) && BKE_collection_has_object(collection, object)) {
return true;
}
}
return false;
}
/* Set the object to override. */
static int make_override_library_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
Object *obact = ED_object_active_context(C);
@ -2255,7 +2268,7 @@ static int make_override_library_invoke(bContext *C, wmOperator *op, const wmEve
if ((!ID_IS_LINKED(obact) && obact->instance_collection != NULL &&
ID_IS_OVERRIDABLE_LIBRARY(obact->instance_collection)) ||
ID_IS_OVERRIDABLE_LIBRARY(obact)) {
make_override_library_ovject_overridable_check(bmain, obact)) {
uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("OK?"), ICON_QUESTION);
uiLayout *layout = UI_popup_menu_layout(pup);
@ -2303,7 +2316,7 @@ static int make_override_library_exec(bContext *C, wmOperator *op)
id_root = &obact->instance_collection->id;
}
else if (!ID_IS_OVERRIDABLE_LIBRARY(obact)) {
else if (!make_override_library_ovject_overridable_check(bmain, obact)) {
const int i = RNA_property_enum_get(op->ptr, op->type->prop);
const uint collection_session_uuid = *((uint *)&i);
if (collection_session_uuid == MAIN_ID_SESSION_UUID_UNSET) {