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
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2008-02-21 19:57:58 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2008-02-21 19:57:58 +0300
commit0d9c6ea649e6e6118afba29e536152f160bf8217 (patch)
tree4427d0b28ff536ca4f971fe5680f8f437564e389 /source/blender/src
parent835624fa050362728f4b8dc6a17a25ca89984be3 (diff)
Fix for bug #6769: lattice editmode undo gave corrupt data
if the lattice resolution changed.
Diffstat (limited to 'source/blender/src')
-rw-r--r--source/blender/src/editarmature.c2
-rw-r--r--source/blender/src/editcurve.c2
-rw-r--r--source/blender/src/editfont.c2
-rw-r--r--source/blender/src/editlattice.c35
-rw-r--r--source/blender/src/editmball.c2
-rw-r--r--source/blender/src/editmesh.c2
-rw-r--r--source/blender/src/editmode_undo.c12
7 files changed, 43 insertions, 14 deletions
diff --git a/source/blender/src/editarmature.c b/source/blender/src/editarmature.c
index 364377f9541..e3ebccca128 100644
--- a/source/blender/src/editarmature.c
+++ b/source/blender/src/editarmature.c
@@ -1565,7 +1565,7 @@ static void free_undoBones(void *lbv)
/* and this is all the undo system needs to know */
void undo_push_armature(char *name)
{
- undo_editmode_push(name, free_undoBones, undoBones_to_editBones, editBones_to_undoBones);
+ undo_editmode_push(name, free_undoBones, undoBones_to_editBones, editBones_to_undoBones, NULL);
}
diff --git a/source/blender/src/editcurve.c b/source/blender/src/editcurve.c
index 8d845c4ba14..aef4d16e5e1 100644
--- a/source/blender/src/editcurve.c
+++ b/source/blender/src/editcurve.c
@@ -4624,7 +4624,7 @@ static void free_undoCurve(void *lbv)
/* and this is all the undo system needs to know */
void undo_push_curve(char *name)
{
- undo_editmode_push(name, free_undoCurve, undoCurve_to_editCurve, editCurve_to_undoCurve);
+ undo_editmode_push(name, free_undoCurve, undoCurve_to_editCurve, editCurve_to_undoCurve, NULL);
}
diff --git a/source/blender/src/editfont.c b/source/blender/src/editfont.c
index 70365c9b234..ac56aec8e51 100644
--- a/source/blender/src/editfont.c
+++ b/source/blender/src/editfont.c
@@ -1283,7 +1283,7 @@ static void free_undoFont(void *strv)
/* and this is all the undo system needs to know */
void undo_push_font(char *name)
{
- undo_editmode_push(name, free_undoFont, undoFont_to_editFont, editFont_to_undoFont);
+ undo_editmode_push(name, free_undoFont, undoFont_to_editFont, editFont_to_undoFont, NULL);
}
diff --git a/source/blender/src/editlattice.c b/source/blender/src/editlattice.c
index f3073cf886a..e80e87b6976 100644
--- a/source/blender/src/editlattice.c
+++ b/source/blender/src/editlattice.c
@@ -294,28 +294,51 @@ void mouse_lattice(void)
/* **************** undo for lattice object ************** */
-static void undoLatt_to_editLatt(void *defv)
+typedef struct UndoLattice {
+ BPoint *def;
+ int pntsu, pntsv, pntsw;
+} UndoLattice;
+
+static void undoLatt_to_editLatt(void *data)
{
+ UndoLattice *ult= (UndoLattice*)data;
int a= editLatt->pntsu*editLatt->pntsv*editLatt->pntsw;
- memcpy(editLatt->def, defv, a*sizeof(BPoint));
+ memcpy(editLatt->def, ult->def, a*sizeof(BPoint));
}
static void *editLatt_to_undoLatt(void)
{
+ UndoLattice *ult= MEM_callocN(sizeof(UndoLattice), "UndoLattice");
+ ult->def= MEM_dupallocN(editLatt->def);
+ ult->pntsu= editLatt->pntsu;
+ ult->pntsv= editLatt->pntsv;
+ ult->pntsw= editLatt->pntsw;
- return MEM_dupallocN(editLatt->def);
+ return ult;
+}
+
+static void free_undoLatt(void *data)
+{
+ UndoLattice *ult= (UndoLattice*)data;
+
+ if(ult->def) MEM_freeN(ult->def);
+ MEM_freeN(ult);
}
-static void free_undoLatt(void *defv)
+static int validate_undoLatt(void *data)
{
- MEM_freeN(defv);
+ UndoLattice *ult= (UndoLattice*)data;
+
+ return (ult->pntsu == editLatt->pntsu &&
+ ult->pntsv == editLatt->pntsv &&
+ ult->pntsw == editLatt->pntsw);
}
/* and this is all the undo system needs to know */
void undo_push_lattice(char *name)
{
- undo_editmode_push(name, free_undoLatt, undoLatt_to_editLatt, editLatt_to_undoLatt);
+ undo_editmode_push(name, free_undoLatt, undoLatt_to_editLatt, editLatt_to_undoLatt, validate_undoLatt);
}
diff --git a/source/blender/src/editmball.c b/source/blender/src/editmball.c
index 71fbf834c17..10ef8756ebf 100644
--- a/source/blender/src/editmball.c
+++ b/source/blender/src/editmball.c
@@ -494,7 +494,7 @@ static void free_undoMball(void *lbv)
/* this is undo system for MetaBalls */
void undo_push_mball(char *name)
{
- undo_editmode_push(name, free_undoMball, undoMball_to_editMball, editMball_to_undoMball);
+ undo_editmode_push(name, free_undoMball, undoMball_to_editMball, editMball_to_undoMball, NULL);
}
/* Hide selected/unselected MetaElems */
diff --git a/source/blender/src/editmesh.c b/source/blender/src/editmesh.c
index ee7c73264e3..de4bcda157f 100644
--- a/source/blender/src/editmesh.c
+++ b/source/blender/src/editmesh.c
@@ -2235,7 +2235,7 @@ static void undoMesh_to_editMesh(void *umv)
/* and this is all the undo system needs to know */
void undo_push_mesh(char *name)
{
- undo_editmode_push(name, free_undoMesh, undoMesh_to_editMesh, editMesh_to_undoMesh);
+ undo_editmode_push(name, free_undoMesh, undoMesh_to_editMesh, editMesh_to_undoMesh, NULL);
}
diff --git a/source/blender/src/editmode_undo.c b/source/blender/src/editmode_undo.c
index 22a399ae1e2..cd7a6c23069 100644
--- a/source/blender/src/editmode_undo.c
+++ b/source/blender/src/editmode_undo.c
@@ -79,6 +79,7 @@ void undo_editmode_push(char *name,
void (*freedata)(void *), // pointer to function freeing data
void (*to_editmode)(void *), // data to editmode conversion
void * (*from_editmode)(void)) // editmode to data conversion
+ int (*validate_undo)(void *)) // check if undo data is still valid
Further exported for UI is:
@@ -96,7 +97,8 @@ void undo_editmode_menu(void) // history menu
void undo_editmode_clear(void); // free & clear all data
void undo_editmode_menu(void); // history menu
void undo_editmode_push(char *name, void (*freedata)(void *),
- void (*to_editmode)(void *), void *(*from_editmode)(void));
+ void (*to_editmode)(void *), void *(*from_editmode)(void),
+ int (*validate_undo)(void *));
struct uiBlock *editmode_undohistorymenu(void *arg_unused);
@@ -112,6 +114,7 @@ typedef struct UndoElem {
void (*freedata)(void *);
void (*to_editmode)(void *);
void * (*from_editmode)(void);
+ int (*validate_undo)(void *);
} UndoElem;
static ListBase undobase={NULL, NULL};
@@ -133,7 +136,8 @@ static void undo_restore(UndoElem *undo)
/* name can be a dynamic string */
void undo_editmode_push(char *name, void (*freedata)(void *),
- void (*to_editmode)(void *), void *(*from_editmode)(void))
+ void (*to_editmode)(void *), void *(*from_editmode)(void),
+ int (*validate_undo)(void *))
{
UndoElem *uel;
int nr;
@@ -157,6 +161,7 @@ void undo_editmode_push(char *name, void (*freedata)(void *),
uel->freedata= freedata;
uel->to_editmode= to_editmode;
uel->from_editmode= from_editmode;
+ uel->validate_undo= validate_undo;
/* and limit amount to the maximum */
nr= 0;
@@ -197,7 +202,8 @@ static void undo_clean_stack(void)
next= uel->next;
/* for when objects are converted, renamed, or global undo changes pointers... */
- if(uel->type==G.obedit->type && strcmp(uel->id.name, G.obedit->id.name)==0) {
+ if(uel->type==G.obedit->type && strcmp(uel->id.name, G.obedit->id.name)==0 &&
+ (!uel->validate_undo || uel->validate_undo(uel->undodata))) {
uel->ob= G.obedit;
}
else {