Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2008-05-26 03:05:13 +0400
committerCampbell Barton <ideasman42@gmail.com>2008-05-26 03:05:13 +0400
commitb7c6da39aedecb59b01ba8f833a8dc61afa89903 (patch)
treef34cf6e60b231e75376c0313fd474b4fd634c3af /source
parent5263021aa8608252a6db44208f2bee89bdc7e4de (diff)
the last selected nurbs curve lastnu could become an invalid pointer in places, access this via functions now and store an index
rather then a pointer so if it becomes invalid it will just return a NULL pointer.
Diffstat (limited to 'source')
-rw-r--r--source/blender/include/BDR_editcurve.h3
-rw-r--r--source/blender/src/buttons_editing.c11
-rw-r--r--source/blender/src/editcurve.c66
3 files changed, 46 insertions, 34 deletions
diff --git a/source/blender/include/BDR_editcurve.h b/source/blender/include/BDR_editcurve.h
index 9e25550ce04..4604359fcc9 100644
--- a/source/blender/include/BDR_editcurve.h
+++ b/source/blender/include/BDR_editcurve.h
@@ -37,6 +37,9 @@ struct BezTriple;
struct BPoint;
struct BezTripleNurb;
+void set_actNurb(struct Nurb *nu);
+struct Nurb * get_actNurb( void );
+
short isNurbsel(struct Nurb *nu);
int isNurbsel_count(struct Nurb *nu);
void printknots(void);
diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c
index 592a8c1b7aa..8a37f713164 100644
--- a/source/blender/src/buttons_editing.c
+++ b/source/blender/src/buttons_editing.c
@@ -3071,7 +3071,6 @@ static void editing_panel_font_type(Object *ob, Curve *cu)
void do_curvebuts(unsigned short event)
{
- extern Nurb *lastnu;
extern ListBase editNurb; /* from editcurve */
Object *ob;
Curve *cu;
@@ -3147,7 +3146,7 @@ void do_curvebuts(unsigned short event)
break;
case B_SETORDER:
if(G.obedit) {
- nu= lastnu;
+ nu= get_actNurb();
if(nu && (nu->type & 7)==CU_NURBS ) {
if(nu->orderu>nu->pntsu) {
nu->orderu= nu->pntsu;
@@ -3273,7 +3272,6 @@ static void editing_panel_curve_tools(Object *ob, Curve *cu)
{
Nurb *nu;
extern ListBase editNurb; /* from editcurve */
- extern Nurb *lastnu;
uiBlock *block;
short *sp;
@@ -3309,8 +3307,11 @@ static void editing_panel_curve_tools(Object *ob, Curve *cu)
uiBlockEndAlign(block);
if(ob==G.obedit) {
- nu= lastnu;
- if(nu==NULL) nu= lastnu= editNurb.first;
+ nu= get_actNurb();
+ if(nu==NULL && editNurb.first) {
+ nu= editNurb.first;
+ set_actNurb(nu);
+ }
if(nu) {
if (ob->type==OB_CURVE) {
uiDefBut(block, LABEL, 0, "Tilt",
diff --git a/source/blender/src/editcurve.c b/source/blender/src/editcurve.c
index 7572391b383..7f9ba2cb8d2 100644
--- a/source/blender/src/editcurve.c
+++ b/source/blender/src/editcurve.c
@@ -99,7 +99,7 @@
ListBase editNurb;
BPoint *lastselbp;
-Nurb *lastnu; /* for selected */
+int actnu; /* for selected */
/* void freeNurblist(ListBase *lb); already declared in the kernel */
@@ -109,6 +109,23 @@ float nurbcircle[8][2]= {
{0.0, 1.0}, { 1.0, 1.0}, { 1.0, 0.0}, { 1.0, -1.0}
};
+
+/* this replaces the active flag used in uv/face mode */
+void set_actNurb(Nurb *nu)
+{
+ if (nu==NULL) {
+ actnu = -1;
+ } else {
+ actnu = BLI_findindex(&editNurb, nu);
+ }
+}
+
+Nurb * get_actNurb( void )
+{
+ return BLI_findlink(&editNurb, actnu);
+}
+
+
/* ******************* SELECTION FUNCTIONS ********************* */
/* returns 1 in case (de)selection was successful */
@@ -325,7 +342,7 @@ void load_editNurb()
}
- lastnu= NULL; /* for selected */
+ set_actNurb(NULL);
}
void make_editNurb()
@@ -361,8 +378,7 @@ void make_editNurb()
else G.obedit= NULL;
countall();
-
- lastnu= NULL; /* for selected */
+ set_actNurb(NULL);
}
void remake_editNurb()
@@ -457,8 +473,7 @@ void separate_nurb()
countall();
allqueue(REDRAWVIEW3D, 0);
allqueue(REDRAWBUTSEDIT, 0);
-
- lastnu= NULL; /* for selected */
+ set_actNurb(NULL);
}
/* ******************* FLAGS ********************* */
@@ -640,7 +655,7 @@ void deleteflagNurb(short flag)
}
if(a==0) {
BLI_remlink(&editNurb, nu);
- freeNurb(nu);
+ freeNurb(nu); nu=NULL;
}
else {
/* is nurb in U direction selected */
@@ -878,7 +893,7 @@ void adduplicateflagNurb(short flag)
newnu = (Nurb*)MEM_mallocN(sizeof(Nurb), "adduplicateN");
memcpy(newnu, nu, sizeof(Nurb));
BLI_addtail(&editNurb, newnu);
- lastnu= newnu;
+ set_actNurb(newnu);
newnu->pntsu= enda-starta+1;
newnu->bezt=
(BezTriple*)MEM_mallocN((enda - starta + 1) * sizeof(BezTriple), "adduplicateN");
@@ -913,7 +928,7 @@ void adduplicateflagNurb(short flag)
if(enda>=starta) {
newnu = (Nurb*)MEM_mallocN(sizeof(Nurb), "adduplicateN3");
memcpy(newnu, nu, sizeof(Nurb));
- lastnu= newnu;
+ set_actNurb(newnu);
BLI_addtail(&editNurb, newnu);
newnu->pntsu= enda-starta+1;
newnu->bp = (BPoint*)MEM_mallocN((enda-starta+1) * sizeof(BPoint), "adduplicateN4");
@@ -971,7 +986,7 @@ void adduplicateflagNurb(short flag)
newnu = (Nurb*)MEM_mallocN(sizeof(Nurb), "adduplicateN5");
memcpy(newnu, nu, sizeof(Nurb));
BLI_addtail(&editNurb, newnu);
- lastnu= newnu;
+ set_actNurb(newnu);
newnu->pntsu= newu;
newnu->pntsv= newv;
newnu->bp =
@@ -1015,7 +1030,7 @@ void adduplicateflagNurb(short flag)
nu= nu->prev;
}
- /* lastnu changed */
+ /* actnu changed */
allqueue(REDRAWBUTSEDIT, 0);
}
@@ -2481,7 +2496,7 @@ void merge_nurb()
BLI_freelistN(&nsortbase);
countall();
- lastnu= NULL;
+ set_actNurb(NULL);
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
@@ -2594,7 +2609,7 @@ void addsegment_nurb()
nu1->bezt= bezt;
nu1->pntsu+= nu2->pntsu;
BLI_remlink(&editNurb, nu2);
- freeNurb(nu2);
+ freeNurb(nu2); nu2= NULL;
calchandlesNurb(nu1);
}
else {
@@ -2632,11 +2647,11 @@ void addsegment_nurb()
}
}
}
- freeNurb(nu2);
+ freeNurb(nu2); nu2= NULL;
}
}
- lastnu= NULL; /* for selected */
+ set_actNurb(NULL); /* for selected */
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
@@ -2704,8 +2719,8 @@ void mouse_nurb()
rightmouse_transform();
- if(nu!=lastnu) {
- lastnu= nu;
+ if(nu!=get_actNurb()) {
+ set_actNurb(nu);
allqueue(REDRAWBUTSEDIT, 0);
}
@@ -3638,7 +3653,7 @@ void delNurb()
}
if(a==0) {
BLI_remlink(&editNurb, nu);
- freeNurb(nu);
+ freeNurb(nu); nu= NULL;
}
}
}
@@ -3654,13 +3669,13 @@ void delNurb()
}
if(a==0) {
BLI_remlink(&editNurb, nu);
- freeNurb(nu);
+ freeNurb(nu); nu= NULL;
}
}
}
/* Never allow the order to exceed the number of points */
- if ((nu->type & 7)==CU_NURBS && (nu->pntsu < nu->orderu)) {
+ if ((nu!= NULL) && ((nu->type & 7)==CU_NURBS) && (nu->pntsu < nu->orderu)) {
nu->orderu = nu->pntsu;
}
nu= next;
@@ -3790,7 +3805,7 @@ void delNurb()
if(bezt1) {
if(nu1->pntsu==2) { /* remove completely */
BLI_remlink(&editNurb, nu);
- freeNurb(nu);
+ freeNurb(nu); nu = NULL;
}
else if(nu1->flagu & 1) { /* cyclic */
bezt =
@@ -3832,7 +3847,7 @@ void delNurb()
else if(bp1) {
if(nu1->pntsu==2) { /* remove completely */
BLI_remlink(&editNurb, nu);
- freeNurb(nu);
+ freeNurb(nu); nu= NULL;
}
else if(nu1->flagu & 1) { /* cyclic */
bp =
@@ -4592,10 +4607,6 @@ static void undoCurve_to_editCurve(void *lbv)
{
ListBase *lb= lbv;
Nurb *nu, *newnu;
- int nr, lastnunr= 0;
-
- /* we try to restore lastnu too, for buttons */
- for(nu= editNurb.first; nu; nu = nu->next, lastnunr++) if(nu==lastnu) break;
freeNurblist(&editNurb);
@@ -4604,9 +4615,6 @@ static void undoCurve_to_editCurve(void *lbv)
newnu= duplicateNurb(nu);
BLI_addtail(&editNurb, newnu);
}
- /* restore */
- for(nr=0, lastnu= editNurb.first; lastnu; lastnu = lastnu->next, nr++) if(nr==lastnunr) break;
-
}
static void *editCurve_to_undoCurve(void)