code cleanup:
authorCampbell Barton <ideasman42@gmail.com>
Sun, 10 Mar 2013 06:40:19 +0000 (06:40 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 10 Mar 2013 06:40:19 +0000 (06:40 +0000)
- remove unused block from before blender was opensourced (BKE_library_make_local)
  noticed by Lawrence D'Oliveiro (ldo)
- remove text_idbutton() unused function.
- test_idbutton(name) was taking (name + 2), then checking 2 bytes before the pointer, this is error prone so better just take the name including the ID prefix.

source/blender/blenkernel/BKE_library.h
source/blender/blenkernel/intern/library.c
source/blender/editors/space_outliner/outliner_draw.c
source/blender/makesrna/intern/rna_ID.c

index 33e1711..816fb2d 100644 (file)
@@ -98,7 +98,6 @@ void tag_main(struct Main *mainvar, const short tag);
 void rename_id(struct ID *id, const char *name);
 void name_uiprefix_id(char *name, const struct ID *id);
 void test_idbutton(char *name);
-void text_idbutton(const struct ID *id, char *text);
 void BKE_library_make_local(struct Main *bmain, struct Library *lib, bool untagged_only);
 struct ID *BKE_libblock_find_name(const short type, const char *name)
 #ifdef __GNUC__
index a251a62..4038dd2 100644 (file)
@@ -1510,7 +1510,7 @@ void tag_main(struct Main *mainvar, const short tag)
  * bmain is almost certainly G.main */
 void BKE_library_make_local(Main *bmain, Library *lib, bool untagged_only)
 {
-       ListBase *lbarray[MAX_LIBARRAY], tempbase = {NULL, NULL};
+       ListBase *lbarray[MAX_LIBARRAY];
        ID *id, *idn;
        int a;
 
@@ -1545,17 +1545,8 @@ void BKE_library_make_local(Main *bmain, Library *lib, bool untagged_only)
                        }
                        id = idn;
                }
-               
-               /* patch2: make it aphabetically */
-               /* FIXME: but nothing is ever put into tempbase! */
-               while ( (id = tempbase.first) ) {
-                       BLI_remlink(&tempbase, id);
-                       BLI_addtail(lbarray[a], id);
-                       new_id(lbarray[a], id, NULL);
-               }
        }
 
-       /* patch 3: make sure library data isn't indirect falsely... */
        a = set_listbasepointers(bmain, lbarray);
        while (a--) {
                for (id = lbarray[a]->first; id; id = id->next)
@@ -1571,43 +1562,17 @@ void test_idbutton(char *name)
        ID *idtest;
        
 
-       lb = which_libbase(G.main, GS(name - 2) );
+       lb = which_libbase(G.main, GS(name) );
        if (lb == NULL) return;
        
        /* search for id */
-       idtest = BLI_findstring(lb, name, offsetof(ID, name) + 2);
+       idtest = BLI_findstring(lb, name + 2, offsetof(ID, name) + 2);
 
-       if (idtest && !new_id(lb, idtest, name)) {
+       if (idtest && !new_id(lb, idtest, name + 2)) {
                id_sort_by_name(lb, idtest);
        }
 }
 
-/**
- * Puts into *text a descriptive block type prefix to be displayed before the block name.
- */
-/* Not actually used anywhere any more. */
-void text_idbutton(const struct ID *id, char *text)
-{
-       if (id) {
-               if (GS(id->name) == ID_SCE)
-                       strcpy(text, "SCE: ");
-               else if (GS(id->name) == ID_SCR)
-                       strcpy(text, "SCR: ");
-               else if (GS(id->name) == ID_MA && ((Material *)id)->use_nodes)
-                       strcpy(text, "NT: ");
-               else {
-                       text[0] = id->name[0];
-                       text[1] = id->name[1];
-                       text[2] = ':';
-                       text[3] = ' ';
-                       text[4] = 0;
-               }
-       }
-       else {
-               text[0] = '\0';
-       }
-}
-
 /**
  * Sets the name of a block to name, suitably adjusted for uniqueness.
  */
index 4819d3b..1700bf0 100644 (file)
@@ -337,7 +337,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
                TreeElement *te = outliner_find_tse(soops, tselem);
                
                if (tselem->type == 0) {
-                       test_idbutton(tselem->id->name + 2);  // library.c, unique name and alpha sort
+                       test_idbutton(tselem->id->name);  // library.c, unique name and alpha sort
                        
                        switch (GS(tselem->id->name)) {
                                case ID_MA:
@@ -372,7 +372,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
                                        defgroup_unique_name(te->directdata, (Object *)tselem->id); //  id = object
                                        break;
                                case TSE_NLA_ACTION:
-                                       test_idbutton(tselem->id->name + 2);
+                                       test_idbutton(tselem->id->name);
                                        break;
                                case TSE_EBONE:
                                {
index 49c0c35..8be468b 100644 (file)
@@ -103,7 +103,7 @@ void rna_ID_name_set(PointerRNA *ptr, const char *value)
 {
        ID *id = (ID *)ptr->data;
        BLI_strncpy_utf8(id->name + 2, value, sizeof(id->name) - 2);
-       test_idbutton(id->name + 2);
+       test_idbutton(id->name);
 }
 
 static int rna_ID_name_editable(PointerRNA *ptr)