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
This commit is contained in:
Ton Roosendaal 2004-11-22 22:41:07 +00:00
parent 0d9fa74348
commit f3c8c47adb
5 changed files with 25 additions and 6 deletions

@ -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);

@ -204,6 +204,7 @@
#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

@ -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);
}

@ -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();
}

@ -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);
}
}
}