use BLI_strncpy and BLI_snprintf when the size of the string is known.
[blender.git] / source / blender / editors / space_outliner / outliner_edit.c
index 2b451a487489b26ec7fe024b10a0cb1e26b254de..0ccbf9127c6bacea87bf2d3c8fff4c869bc69704 100644 (file)
@@ -213,20 +213,25 @@ void OUTLINER_OT_item_openclose(wmOperatorType *ot)
        
        ot->poll= ED_operator_outliner_active;
        
        
        ot->poll= ED_operator_outliner_active;
        
-       RNA_def_boolean(ot->srna, "all", 1, "All", "Close or open all items.");
+       RNA_def_boolean(ot->srna, "all", 1, "All", "Close or open all items");
 }
 
 /* Rename --------------------------------------------------- */
 
 }
 
 /* Rename --------------------------------------------------- */
 
-void do_item_rename(ARegion *ar, TreeElement *te, TreeStoreElem *tselem, ReportList *reports)
+static void do_item_rename(ARegion *ar, TreeElement *te, TreeStoreElem *tselem, ReportList *reports)
 {
        /* can't rename rna datablocks entries */
 {
        /* can't rename rna datablocks entries */
-       if(ELEM3(tselem->type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM))
-                       ;
-       else if(ELEM10(tselem->type, TSE_ANIM_DATA, TSE_NLA, TSE_DEFGROUP_BASE, TSE_CONSTRAINT_BASE, TSE_MODIFIER_BASE, TSE_SCRIPT_BASE, TSE_POSE_BASE, TSE_POSEGRP_BASE, TSE_R_LAYER_BASE, TSE_R_PASS)) 
+       if(ELEM3(tselem->type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) {
+                       /* do nothing */;
+       }
+       else if(ELEM10(tselem->type, TSE_ANIM_DATA, TSE_NLA, TSE_DEFGROUP_BASE, TSE_CONSTRAINT_BASE, TSE_MODIFIER_BASE,
+                                    TSE_SCRIPT_BASE, TSE_POSE_BASE, TSE_POSEGRP_BASE, TSE_R_LAYER_BASE, TSE_R_PASS))
+       {
                        BKE_report(reports, RPT_WARNING, "Cannot edit builtin name");
                        BKE_report(reports, RPT_WARNING, "Cannot edit builtin name");
-       else if(ELEM3(tselem->type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP))
+       }
+       else if(ELEM3(tselem->type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)) {
                BKE_report(reports, RPT_WARNING, "Cannot edit sequence name");
                BKE_report(reports, RPT_WARNING, "Cannot edit sequence name");
+       }
        else if(tselem->id->lib) {
                // XXX                                          error_libdata();
        } 
        else if(tselem->id->lib) {
                // XXX                                          error_libdata();
        } 
@@ -669,7 +674,7 @@ void OUTLINER_OT_scroll_page(wmOperatorType *ot)
        ot->poll= ED_operator_outliner_active;
        
        /* properties */
        ot->poll= ED_operator_outliner_active;
        
        /* properties */
-       RNA_def_boolean(ot->srna, "up", 0, "Up", "Scroll up one page.");
+       RNA_def_boolean(ot->srna, "up", 0, "Up", "Scroll up one page");
 }
 
 /* Search ------------------------------------------------------- */
 }
 
 /* Search ------------------------------------------------------- */
@@ -687,7 +692,7 @@ static void outliner_set_coordinates_element(SpaceOops *soops, TreeElement *te,
        te->ys= (float)(*starty);
        *starty-= UI_UNIT_Y;
        
        te->ys= (float)(*starty);
        *starty-= UI_UNIT_Y;
        
-       if((tselem->flag & TSE_CLOSED)==0) {
+       if(TSELEM_OPEN(tselem,soops)) {
                TreeElement *ten;
                for(ten= te->subtree.first; ten; ten= ten->next) {
                        outliner_set_coordinates_element(soops, ten, startx+UI_UNIT_X, starty);
                TreeElement *ten;
                for(ten= te->subtree.first; ten; ten= ten->next) {
                        outliner_set_coordinates_element(soops, ten, startx+UI_UNIT_X, starty);
@@ -744,7 +749,7 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so
        TreeElement *last_find;
        TreeStoreElem *tselem;
        int ytop, xdelta, prevFound=0;
        TreeElement *last_find;
        TreeStoreElem *tselem;
        int ytop, xdelta, prevFound=0;
-       char name[32];
+       char name[sizeof(soops->search_string)];
        
        /* get last found tree-element based on stored search_tse */
        last_find= outliner_find_tse(soops, &soops->search_tse);
        
        /* get last found tree-element based on stored search_tse */
        last_find= outliner_find_tse(soops, &soops->search_tse);
@@ -765,7 +770,7 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so
        }
        else {
                /* pop up panel - no previous, or user didn't want search after previous */
        }
        else {
                /* pop up panel - no previous, or user didn't want search after previous */
-               strcpy(name, "");
+               name[0]= '\0';
 // XXX         if (sbutton(name, 0, sizeof(name)-1, "Find: ") && name[0]) {
 //                     te= outliner_find_named(soops, &soops->tree, name, flags, NULL, &prevFound);
 //             }
 // XXX         if (sbutton(name, 0, sizeof(name)-1, "Find: ") && name[0]) {
 //                     te= outliner_find_named(soops, &soops->tree, name, flags, NULL, &prevFound);
 //             }
@@ -798,7 +803,7 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so
                        /* store selection */
                        soops->search_tse= *tselem;
                        
                        /* store selection */
                        soops->search_tse= *tselem;
                        
-                       BLI_strncpy(soops->search_string, name, 33);
+                       BLI_strncpy(soops->search_string, name, sizeof(soops->search_string));
                        soops->search_flags= flags;
                        
                        /* redraw */
                        soops->search_flags= flags;
                        
                        /* redraw */
@@ -869,7 +874,7 @@ void OUTLINER_OT_show_one_level(wmOperatorType *ot)
        /* no undo or registry, UI option */
        
        /* properties */
        /* no undo or registry, UI option */
        
        /* properties */
-       RNA_def_boolean(ot->srna, "open", 1, "Open", "Expand all entries one level deep.");
+       RNA_def_boolean(ot->srna, "open", 1, "Open", "Expand all entries one level deep");
 }
 
 /* Show Hierarchy ----------------------------------------------- */
 }
 
 /* Show Hierarchy ----------------------------------------------- */
@@ -910,7 +915,7 @@ static void tree_element_show_hierarchy(Scene *scene, SpaceOops *soops, ListBase
                }
                else tselem->flag |= TSE_CLOSED;
                
                }
                else tselem->flag |= TSE_CLOSED;
                
-               if(tselem->flag & TSE_CLOSED); else tree_element_show_hierarchy(scene, soops, &te->subtree);
+               if(TSELEM_OPEN(tselem,soops)) tree_element_show_hierarchy(scene, soops, &te->subtree);
        }
 }
 
        }
 }
 
@@ -947,7 +952,7 @@ void OUTLINER_OT_show_hierarchy(wmOperatorType *ot)
 /* ANIMATO OPERATIONS */
 /* KeyingSet and Driver Creation - Helper functions */
 
 /* ANIMATO OPERATIONS */
 /* KeyingSet and Driver Creation - Helper functions */
 
-/* specialised poll callback for these operators to work in Datablocks view only */
+/* specialized poll callback for these operators to work in Datablocks view only */
 static int ed_operator_outliner_datablocks_active(bContext *C)
 {
        ScrArea *sa= CTX_wm_area(C);
 static int ed_operator_outliner_datablocks_active(bContext *C)
 {
        ScrArea *sa= CTX_wm_area(C);
@@ -969,7 +974,7 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle
        ListBase hierarchy = {NULL, NULL};
        LinkData *ld;
        TreeElement *tem, *temnext, *temsub;
        ListBase hierarchy = {NULL, NULL};
        LinkData *ld;
        TreeElement *tem, *temnext, *temsub;
-       TreeStoreElem *tse, *tsenext;
+       TreeStoreElem *tse /* , *tsenext */ /* UNUSED */;
        PointerRNA *ptr, *nextptr;
        PropertyRNA *prop;
        char *newpath=NULL;
        PointerRNA *ptr, *nextptr;
        PropertyRNA *prop;
        char *newpath=NULL;
@@ -1018,10 +1023,10 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle
                                        char buf[128], *name;
                                        
                                        temnext= (TreeElement*)(ld->next->data);
                                        char buf[128], *name;
                                        
                                        temnext= (TreeElement*)(ld->next->data);
-                                       tsenext= TREESTORE(temnext);
+                                       /* tsenext= TREESTORE(temnext); */ /* UNUSED */
                                        
                                        nextptr= &temnext->rnaptr;
                                        
                                        nextptr= &temnext->rnaptr;
-                                       name= RNA_struct_name_get_alloc(nextptr, buf, sizeof(buf));
+                                       name= RNA_struct_name_get_alloc(nextptr, buf, sizeof(buf), NULL);
                                        
                                        if(name) {
                                                /* if possible, use name as a key in the path */
                                        
                                        if(name) {
                                                /* if possible, use name as a key in the path */
@@ -1175,7 +1180,7 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportL
                }
                
                /* go over sub-tree */
                }
                
                /* go over sub-tree */
-               if ((tselem->flag & TSE_CLOSED)==0)
+               if (TSELEM_OPEN(tselem,soops))
                        do_outliner_drivers_editop(soops, &te->subtree, reports, mode);
        }
 }
                        do_outliner_drivers_editop(soops, &te->subtree, reports, mode);
        }
 }
@@ -1343,7 +1348,7 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa
                }
                
                /* go over sub-tree */
                }
                
                /* go over sub-tree */
-               if ((tselem->flag & TSE_CLOSED)==0)
+               if (TSELEM_OPEN(tselem,soops))
                        do_outliner_keyingset_editop(soops, ks, &te->subtree, mode);
        }
 }
                        do_outliner_keyingset_editop(soops, ks, &te->subtree, mode);
        }
 }