Fix for #1839
authorTon Roosendaal <ton@blender.org>
Mon, 22 Nov 2004 22:41:07 +0000 (22:41 +0000)
committerTon Roosendaal <ton@blender.org>
Mon, 22 Nov 2004 22:41:07 +0000 (22:41 +0000)
On large changes of the Lattice resolution button, the undopush crashed.
Reason was that the push happened for buttons before the actual event for
buttons was executed.
Solved by creating new event UNDOPUSH that's being added to the queue by
by buttons now.

- Made button undo texts for number buttons more clear
- Added undo push for missing Add lamp/empty/lattice/camera

source/blender/include/BIF_screen.h
source/blender/include/mydevice.h
source/blender/src/editobject.c
source/blender/src/editscreen.c
source/blender/src/interface.c

index b211c333fadcc0398d8e6a871878f9e743771ca4..94b5edb41805118fa7144d519e8cf7bdff72d62d 100644 (file)
@@ -98,6 +98,7 @@ void screen_swapbuffers(void);
 void set_debug_swapbuffers_ovveride(struct bScreen *sc, int mode);
 int is_allowed_to_change_screen(struct bScreen *newp);
 void splash(void * data, int datasizei, char * string);
+void screen_delayed_undo_push(char *name);
 void screenmain(void);
 void getdisplaysize(void);
 void setprefsize(int stax, int stay, int sizx, int sizy);
index b8832606c6df0e15a21059572f35eeef30b36a13..18c3784ae08f479ee49fda425c5bc89cc02b0012 100644 (file)
 #define RESHAPE                                0x4007
 #define UI_BUT_EVENT           0x4008
 #define AUTOSAVE_FILE          0x4009
+#define UNDOPUSH                       0x400A
 
 /* REDRAWVIEW3D has to be the first one (lowest number) for buttons! */
 #define REDRAWVIEW3D           0x4010
index c23a31b7eb3dec526d6c923eb61d53fe97e32bf1..aff43653fb2c34b9203c6f170d18fbb28a4e8ffa 100644 (file)
@@ -187,7 +187,7 @@ float centre[3], centroid[3];
 
 void mirrormenu(void);
 
-void add_object_draw(int type) /* for toolbox */
+void add_object_draw(int type) /* for toolbox or menus, only non-editmode stuff */
 {
        Object *ob;
        
@@ -198,7 +198,12 @@ void add_object_draw(int type)     /* for toolbox */
                if (G.obedit) exit_editmode(2); // freedata, and undo
                ob= add_object(type);
                base_init_from_view3d(BASACT, G.vd);
-
+               
+               if(type==OB_EMPTY) BIF_undo_push("Add Empty");
+               else if(type==OB_LAMP) BIF_undo_push("Add Lamp");
+               else if(type==OB_LATTICE) BIF_undo_push("Add Lattice");
+               else BIF_undo_push("Add Camera");
+               
                allqueue(REDRAWVIEW3D, 0);
        }
 
index 93ea0a6c40c3051ba5406cd2bd8eebd421c97792..6539eb8a44774f9838936cf16560e2be5f5ab00f 100644 (file)
@@ -1003,6 +1003,15 @@ static ScrArea *screen_find_area_for_pt(bScreen *sc, short *mval)
        return NULL;
 }
 
+/* ugly yah, will disappear on better event system */
+/* is called from interface.c after button events */
+static char delayed_undo_name[64];
+void screen_delayed_undo_push(char *name)
+{
+       strncpy(delayed_undo_name, name, 63);
+       mainqenter(UNDOPUSH, 1);
+}
+
 void screenmain(void)
 {
        int has_input= 1;
@@ -1097,6 +1106,9 @@ void screenmain(void)
                        markdirty_all();
                        dodrawscreen= 1;
                }
+               else if( event==UNDOPUSH) {
+                       BIF_undo_push(delayed_undo_name);
+               }
                else if (event==AUTOSAVE_FILE) {
                        BIF_write_autosave();
                }
index 84fd6421d2f23eb1d177e336571f23dd66325842..873b1baab7daea2bd1cc4a9848192b68d26a346c 100644 (file)
@@ -3342,10 +3342,10 @@ static int ui_do_block(uiBlock *block, uiEvent *uevent)
                                                                if ELEM4(but->type, BLOCK, BUT, LABEL, PULLDOWN); 
                                                                else {
                                                                        /* define which string to use for undo */
-                                                                       if ELEM(but->type, LINK, INLINK) BIF_undo_push("Add button link");
-                                                                       else if ELEM(but->type, MENU, ICONTEXTROW) BIF_undo_push(but->drawstr);
-                                                                       else if(but->str[0]) BIF_undo_push(but->str);
-                                                                       else BIF_undo_push(but->tip);
+                                                                       if ELEM(but->type, LINK, INLINK) screen_delayed_undo_push("Add button link");
+                                                                       else if ELEM(but->type, MENU, ICONTEXTROW) screen_delayed_undo_push(but->drawstr);
+                                                                       else if(but->drawstr[0]) screen_delayed_undo_push(but->drawstr);
+                                                                       else screen_delayed_undo_push(but->tip);
                                                                }
                                                        }
                                                }