Fixes related to using Library files:
authorTon Roosendaal <ton@blender.org>
Fri, 8 Apr 2011 16:56:44 +0000 (16:56 +0000)
committerTon Roosendaal <ton@blender.org>
Fri, 8 Apr 2011 16:56:44 +0000 (16:56 +0000)
- 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
source/blender/blenkernel/intern/material.c
source/blender/editors/interface/interface_templates.c
source/blender/editors/render/render_shading.c
source/blender/makesrna/intern/rna_scene.c

index 2400a45620ad4f137e8c177f37d1529b8a9896f1..ae66642e9031987a56f31f832703b0f4ac277d6d 100644 (file)
@@ -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):
index ce4c3a21d805ddadeb6947abb3058bb0f8827821..daa665f7183084f21b71d11a578427dfecaf2ef9 100644 (file)
@@ -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);
index 42b6926e847d69d669771dee4d03feb84b8825e7..01e785ef88cbbbd028b93ed928df0e4721e2ff67 100644 (file)
@@ -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);
                }
        }
index 2fe8533c04c5df89a6ae44e60134266ce41284c5..306e9f977de75f5655fa4c523b5a278f3104d71d 100644 (file)
 #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;
index 8ebb71c33d056fd998ca14ceddb6a8873c5e6388..331d9cfa95713e4220988e85ab3d0e54625da247 100644 (file)
@@ -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 */