[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30656] trunk/blender/source/blender/ editors: Fix #21028: operator redo creates hundreds of images when texture paint is on.
Brecht Van Lommel
brecht at blender.org
Fri Jul 23 16:46:31 CEST 2010
Revision: 30656
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30656
Author: blendix
Date: 2010-07-23 16:46:31 +0200 (Fri, 23 Jul 2010)
Log Message:
-----------
Fix #21028: operator redo creates hundreds of images when texture paint is on.
Now operator redo will look for an undo push with the same name in both the
paint/sculpt and global undo stack.
Modified Paths:
--------------
trunk/blender/source/blender/editors/include/ED_sculpt.h
trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h
trunk/blender/source/blender/editors/sculpt_paint/paint_undo.c
trunk/blender/source/blender/editors/space_view3d/view3d_draw.c
trunk/blender/source/blender/editors/util/undo.c
Modified: trunk/blender/source/blender/editors/include/ED_sculpt.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_sculpt.h 2010-07-23 14:35:23 UTC (rev 30655)
+++ trunk/blender/source/blender/editors/include/ED_sculpt.h 2010-07-23 14:46:31 UTC (rev 30656)
@@ -49,7 +49,7 @@
#define UNDO_PAINT_IMAGE 0
#define UNDO_PAINT_MESH 1
-void ED_undo_paint_step(struct bContext *C, int type, int step);
+int ED_undo_paint_step(struct bContext *C, int type, int step, const char *name);
void ED_undo_paint_free(void);
#endif
Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_image.c 2010-07-23 14:35:23 UTC (rev 30655)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_image.c 2010-07-23 14:46:31 UTC (rev 30656)
@@ -4699,7 +4699,7 @@
}
settings->imapaint.flag |= IMAGEPAINT_DRAWING;
- undo_paint_push_begin(UNDO_PAINT_IMAGE, "Image Paint",
+ undo_paint_push_begin(UNDO_PAINT_IMAGE, op->type->name,
image_undo_restore, image_undo_free);
/* create painter */
@@ -5440,7 +5440,7 @@
scene->toolsettings->imapaint.flag |= IMAGEPAINT_DRAWING;
- undo_paint_push_begin(UNDO_PAINT_IMAGE, "Image Paint",
+ undo_paint_push_begin(UNDO_PAINT_IMAGE, op->type->name,
image_undo_restore, image_undo_free);
/* allocate and initialize spacial data structures */
Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h 2010-07-23 14:35:23 UTC (rev 30655)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h 2010-07-23 14:46:31 UTC (rev 30656)
@@ -121,7 +121,7 @@
typedef void (*UndoRestoreCb)(struct bContext *C, struct ListBase *lb);
typedef void (*UndoFreeCb)(struct ListBase *lb);
-void undo_paint_push_begin(int type, char *name, UndoRestoreCb restore, UndoFreeCb free);
+void undo_paint_push_begin(int type, const char *name, UndoRestoreCb restore, UndoFreeCb free);
struct ListBase *undo_paint_push_get_list(int type);
void undo_paint_push_count_alloc(int type, int size);
void undo_paint_push_end(int type);
Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_undo.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_undo.c 2010-07-23 14:35:23 UTC (rev 30655)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_undo.c 2010-07-23 14:46:31 UTC (rev 30656)
@@ -76,7 +76,7 @@
}
}
-static void undo_stack_push_begin(UndoStack *stack, char *name, UndoRestoreCb restore, UndoFreeCb free)
+static void undo_stack_push_begin(UndoStack *stack, const char *name, UndoRestoreCb restore, UndoFreeCb free)
{
UndoElem *uel;
int nr;
@@ -145,27 +145,35 @@
}
}
-static void undo_stack_step(bContext *C, UndoStack *stack, int step)
+static int undo_stack_step(bContext *C, UndoStack *stack, int step, const char *name)
{
UndoElem *undo;
if(step==1) {
if(stack->current==NULL);
else {
- if(G.f & G_DEBUG) printf("undo %s\n", stack->current->name);
- undo_restore(C, stack, stack->current);
- stack->current= stack->current->prev;
+ if(!name || strcmp(stack->current->name, name) == 0) {
+ if(G.f & G_DEBUG) printf("undo %s\n", stack->current->name);
+ undo_restore(C, stack, stack->current);
+ stack->current= stack->current->prev;
+ return 1;
+ }
}
}
else if(step==-1) {
if((stack->current!=NULL && stack->current->next==NULL) || stack->elems.first==NULL);
else {
- undo= (stack->current && stack->current->next)? stack->current->next: stack->elems.first;
- undo_restore(C, stack, undo);
- stack->current= undo;
- if(G.f & G_DEBUG) printf("redo %s\n", undo->name);
+ if(!name || strcmp(stack->current->name, name) == 0) {
+ undo= (stack->current && stack->current->next)? stack->current->next: stack->elems.first;
+ undo_restore(C, stack, undo);
+ stack->current= undo;
+ if(G.f & G_DEBUG) printf("redo %s\n", undo->name);
+ return 1;
+ }
}
}
+
+ return 0;
}
static void undo_stack_free(UndoStack *stack)
@@ -181,7 +189,7 @@
/* Exported Functions */
-void undo_paint_push_begin(int type, char *name, UndoRestoreCb restore, UndoFreeCb free)
+void undo_paint_push_begin(int type, const char *name, UndoRestoreCb restore, UndoFreeCb free)
{
if(type == UNDO_PAINT_IMAGE)
undo_stack_push_begin(&ImageUndoStack, name, restore, free);
@@ -219,12 +227,14 @@
undo_stack_push_end(&MeshUndoStack);
}
-void ED_undo_paint_step(bContext *C, int type, int step)
+int ED_undo_paint_step(bContext *C, int type, int step, const char *name)
{
if(type == UNDO_PAINT_IMAGE)
- undo_stack_step(C, &ImageUndoStack, step);
+ return undo_stack_step(C, &ImageUndoStack, step, name);
else if(type == UNDO_PAINT_MESH)
- undo_stack_step(C, &MeshUndoStack, step);
+ return undo_stack_step(C, &MeshUndoStack, step, name);
+
+ return 0;
}
void ED_undo_paint_free(void)
Modified: trunk/blender/source/blender/editors/space_view3d/view3d_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_draw.c 2010-07-23 14:35:23 UTC (rev 30655)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_draw.c 2010-07-23 14:46:31 UTC (rev 30656)
@@ -1063,7 +1063,7 @@
/* *********************** backdraw for selection *************** */
-void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d)
+static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d)
{
RegionView3D *rv3d= ar->regiondata;
struct Base *base = scene->basact;
Modified: trunk/blender/source/blender/editors/util/undo.c
===================================================================
--- trunk/blender/source/blender/editors/util/undo.c 2010-07-23 14:35:23 UTC (rev 30655)
+++ trunk/blender/source/blender/editors/util/undo.c 2010-07-23 14:46:31 UTC (rev 30656)
@@ -116,7 +116,9 @@
SpaceImage *sima= (SpaceImage *)sa->spacedata.first;
if((obact && obact->mode & OB_MODE_TEXTURE_PAINT) || sima->flag & SI_DRAWTOOL) {
- ED_undo_paint_step(C, UNDO_PAINT_IMAGE, step);
+ if(!ED_undo_paint_step(C, UNDO_PAINT_IMAGE, step, undoname) && undoname)
+ if(U.uiflag & USER_GLOBALUNDO)
+ BKE_undo_name(C, undoname);
WM_event_add_notifier(C, NC_WINDOW, NULL);
return OPERATOR_FINISHED;
@@ -139,10 +141,14 @@
else {
int do_glob_undo= 0;
- if(obact && obact->mode & OB_MODE_TEXTURE_PAINT)
- ED_undo_paint_step(C, UNDO_PAINT_IMAGE, step);
- else if(obact && obact->mode & OB_MODE_SCULPT)
- ED_undo_paint_step(C, UNDO_PAINT_MESH, step);
+ if(obact && obact->mode & OB_MODE_TEXTURE_PAINT) {
+ if(!ED_undo_paint_step(C, UNDO_PAINT_IMAGE, step, undoname) && undoname)
+ do_glob_undo= 1;
+ }
+ else if(obact && obact->mode & OB_MODE_SCULPT) {
+ if(!ED_undo_paint_step(C, UNDO_PAINT_MESH, step, undoname) && undoname)
+ do_glob_undo= 1;
+ }
else if(obact && obact->mode & OB_MODE_PARTICLE_EDIT) {
if(step==1)
PE_undo(CTX_data_scene(C));
More information about the Bf-blender-cvs
mailing list