svn merge -r 21041:21301 https://svn.blender.org/svnroot/bf-blender/branches/blender2...
[blender.git] / source / blender / editors / space_buttons / buttons_context.c
index fc280d9b5515ce65a90b22a6b8a760cd3f56241d..01794d1bba805f0988470f4e43797aaff9179142 100644 (file)
@@ -492,8 +492,17 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
                return 0;
 
        /* here we handle context, getting data from precomputed path */
-
-       if(CTX_data_equals(member, "world")) {
+       if(CTX_data_dir(member)) {
+               static const char *dir[] = {
+                       "world", "object", "meshe", "armature", "lattice", "curve",
+                       "meta_ball", "lamp", "camera", "material", "material_slot",
+                       "texture", "texture_slot", "bone", "edit_bone", "particle_system",
+                       "cloth", "soft_body", "fluid", NULL};
+
+               CTX_data_dir_set(result, dir);
+               return 1;
+       }
+       else if(CTX_data_equals(member, "world")) {
                set_pointer_type(path, result, &RNA_World);
                return 1;
        }
@@ -543,7 +552,7 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
                if(ptr) {
                        Object *ob= ptr->data;
 
-                       if(ob && ob->type && (ob->type<OB_LAMP))
+                       if(ob && ob->type && (ob->type<OB_LAMP) && ob->totcol)
                                CTX_data_pointer_set(result, &ob->id, &RNA_MaterialSlot, ob->mat+ob->actcol-1);
                }
 
@@ -659,7 +668,6 @@ void buttons_context_draw(const bContext *C, uiLayout *layout)
        uiBlock *block;
        uiBut *but;
        PointerRNA *ptr;
-       PropertyRNA *nameprop;
        char namebuf[128], *name;
        int a, icon;
 
@@ -679,7 +687,7 @@ void buttons_context_draw(const bContext *C, uiLayout *layout)
 
                if(ptr->data) {
                        icon= RNA_struct_ui_icon(ptr->type);
-                       nameprop= RNA_struct_name_property(ptr->type);
+                       name= RNA_struct_name_get_alloc(ptr, namebuf, sizeof(namebuf));
 
 #if 0
                        if(sbuts->mainb != BCONTEXT_SCENE && ptr->type == &RNA_Scene) {
@@ -687,9 +695,7 @@ void buttons_context_draw(const bContext *C, uiLayout *layout)
                        }
                        else
 #endif
-                       if(nameprop) {
-                               name= RNA_property_string_get_alloc(ptr, nameprop, namebuf, sizeof(namebuf));
-
+                       if(name) {
                                uiItemL(row, name, icon);
 
                                if(name != namebuf)