fix [#31019] [Minor] Freshly added nodes aren't getting undo push

also noticed ED_undo_push was checking USER_GLOBALUNDO unnecessarily
This commit is contained in:
Campbell Barton 2012-09-12 11:09:27 +00:00
parent d86f1f67fd
commit db1191d451
2 changed files with 12 additions and 5 deletions

@ -41,6 +41,7 @@
#include "BLF_translation.h" #include "BLF_translation.h"
#include "BKE_blender.h"
#include "BKE_context.h" #include "BKE_context.h"
#include "BKE_global.h" #include "BKE_global.h"
#include "BKE_main.h" #include "BKE_main.h"
@ -64,7 +65,7 @@ static void do_node_add(bContext *C, bNodeTemplate *ntemp)
SpaceNode *snode = CTX_wm_space_node(C); SpaceNode *snode = CTX_wm_space_node(C);
ScrArea *sa = CTX_wm_area(C); ScrArea *sa = CTX_wm_area(C);
ARegion *ar; ARegion *ar;
bNode *node; bNode *node, *node_new;
/* get location to add node at mouse */ /* get location to add node at mouse */
for (ar = sa->regionbase.first; ar; ar = ar->next) { for (ar = sa->regionbase.first; ar; ar = ar->next) {
@ -84,7 +85,7 @@ static void do_node_add(bContext *C, bNodeTemplate *ntemp)
else node->flag &= ~NODE_TEST; else node->flag &= ~NODE_TEST;
} }
/* node= */ node_add_node(snode, bmain, scene, ntemp, snode->cursor[0], snode->cursor[1]); node_new = node_add_node(snode, bmain, scene, ntemp, snode->cursor[0], snode->cursor[1]);
/* select previous selection before autoconnect */ /* select previous selection before autoconnect */
for (node = snode->edittree->nodes.first; node; node = node->next) { for (node = snode->edittree->nodes.first; node; node = node->next) {
@ -95,7 +96,14 @@ static void do_node_add(bContext *C, bNodeTemplate *ntemp)
for (node = snode->edittree->nodes.first; node; node = node->next) { for (node = snode->edittree->nodes.first; node; node = node->next) {
if (node->flag & NODE_TEST) node->flag &= ~NODE_SELECT; if (node->flag & NODE_TEST) node->flag &= ~NODE_SELECT;
} }
/* once this is called from an operator, this should be removed */
if (node_new) {
char undostr[BKE_UNDO_STR_MAX];
BLI_snprintf(undostr, sizeof(BKE_UNDO_STR_MAX), "Add Node %s", nodeLabel(node_new));
BKE_write_undo(C, undostr);
}
snode_notify(C, snode); snode_notify(C, snode);
snode_dag_update(C, snode); snode_dag_update(C, snode);
} }

@ -107,8 +107,7 @@ void ED_undo_push(bContext *C, const char *str)
PE_undo_push(CTX_data_scene(C), str); PE_undo_push(CTX_data_scene(C), str);
} }
else { else {
if (U.uiflag & USER_GLOBALUNDO) BKE_write_undo(C, str);
BKE_write_undo(C, str);
} }
if (wm->file_saved) { if (wm->file_saved) {