Fix for bug #6769: lattice editmode undo gave corrupt data
if the lattice resolution changed.
This commit is contained in:
@@ -39,7 +39,8 @@
|
||||
extern 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
|
||||
void *(*from_editmode)(void), // editmode to data conversion
|
||||
int (*validate_undo)(void *)); // check if undo data is still valid
|
||||
|
||||
|
||||
// Further exported for UI is:
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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 *defv)
|
||||
static void free_undoLatt(void *data)
|
||||
{
|
||||
MEM_freeN(defv);
|
||||
UndoLattice *ult= (UndoLattice*)data;
|
||||
|
||||
if(ult->def) MEM_freeN(ult->def);
|
||||
MEM_freeN(ult);
|
||||
}
|
||||
|
||||
static int validate_undoLatt(void *data)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user