From 1728c20a63123f1377f7192c1bd521286eac2228 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Fri, 8 Apr 2011 16:56:44 +0000 Subject: [PATCH] Fixes related to using Library files: - Assigning local materials to library objects disabled (crashes on undo/redo cases) - Disabling options in Material buttons to add/remove slots on library data - Drawing Object ID template in Object properties, this allows browse active Object, but especially shows library status then. --- release/scripts/startup/bl_ui/properties_object.py | 3 +-- source/blender/blenkernel/intern/material.c | 3 +++ source/blender/editors/interface/interface_templates.c | 2 +- source/blender/editors/render/render_shading.c | 6 +++++- source/blender/makesrna/intern/rna_scene.c | 2 +- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py index 2400a45620a..ae66642e903 100644 --- a/release/scripts/startup/bl_ui/properties_object.py +++ b/release/scripts/startup/bl_ui/properties_object.py @@ -40,8 +40,7 @@ class OBJECT_PT_context_object(ObjectButtonsPanel, bpy.types.Panel): layout.template_ID(space, "pin_id") else: row = layout.row() - row.label(text="", icon='OBJECT_DATA') - row.prop(ob, "name", text="") + row.template_ID(context.scene.objects, "active") class OBJECT_PT_transform(ObjectButtonsPanel, bpy.types.Panel): diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index ce4c3a21d80..daa665f7183 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -687,6 +687,9 @@ void assign_material(Object *ob, Material *ma, int act) if(act>MAXMAT) return; if(act<1) act= 1; + /* prevent crashing when using accidentally */ + if(ob->id.lib) return; + /* test arraylens */ totcolp= give_totcolp(ob); diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 42b6926e847..01e785ef88c 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -416,7 +416,7 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str if(user_alert) uiButSetFlag(but, UI_BUT_REDALERT); - if(id->lib == NULL && !(ELEM4(GS(id->name), ID_GR, ID_SCE, ID_SCR, ID_TXT))) { + if(id->lib == NULL && !(ELEM5(GS(id->name), ID_GR, ID_SCE, ID_SCR, ID_TXT, ID_OB))) { uiDefButR(block, TOG, 0, "F", 0, 0, UI_UNIT_X, UI_UNIT_Y, &idptr, "use_fake_user", -1, 0, 0, -1, -1, NULL); } } diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 2fe8533c04c..306e9f977de 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -76,9 +76,10 @@ #include "WM_api.h" #include "WM_types.h" -#include "ED_render.h" #include "ED_curve.h" #include "ED_mesh.h" +#include "ED_render.h" +#include "ED_screen.h" #include "RNA_define.h" @@ -285,6 +286,7 @@ void OBJECT_OT_material_slot_add(wmOperatorType *ot) /* api callbacks */ ot->exec= material_slot_add_exec; + ot->poll= ED_operator_object_active_editable; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -320,6 +322,7 @@ void OBJECT_OT_material_slot_remove(wmOperatorType *ot) /* api callbacks */ ot->exec= material_slot_remove_exec; + ot->poll= ED_operator_object_active_editable; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -379,6 +382,7 @@ void OBJECT_OT_material_slot_assign(wmOperatorType *ot) /* api callbacks */ ot->exec= material_slot_assign_exec; + ot->poll= ED_operator_object_active_editable; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 8ebb71c33d0..331d9cfa957 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2988,7 +2988,7 @@ static void rna_def_scene_objects(BlenderRNA *brna, PropertyRNA *cprop) prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "Object"); RNA_def_property_pointer_funcs(prop, "rna_Scene_active_object_get", "rna_Scene_active_object_set", NULL, NULL); - RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_EDITABLE|PROP_NEVER_UNLINK); RNA_def_property_ui_text(prop, "Active Object", "Active object for this scene"); /* Could call: ED_base_object_activate(C, scene->basact); * but would be a bad level call and it seems the notifier is enough */