From db1191d4519251ed93b570f0e09b375c249a4ef2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 12 Sep 2012 11:09:27 +0000 Subject: fix [#31019] [Minor] Freshly added nodes aren't getting undo push also noticed ED_undo_push was checking USER_GLOBALUNDO unnecessarily --- source/blender/editors/space_node/node_header.c | 14 +++++++++++--- source/blender/editors/util/undo.c | 3 +-- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'source') diff --git a/source/blender/editors/space_node/node_header.c b/source/blender/editors/space_node/node_header.c index f461174d74f..e17961b6c7c 100644 --- a/source/blender/editors/space_node/node_header.c +++ b/source/blender/editors/space_node/node_header.c @@ -41,6 +41,7 @@ #include "BLF_translation.h" +#include "BKE_blender.h" #include "BKE_context.h" #include "BKE_global.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); ScrArea *sa = CTX_wm_area(C); ARegion *ar; - bNode *node; + bNode *node, *node_new; /* get location to add node at mouse */ 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; } - /* 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 */ 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) { 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_dag_update(C, snode); } diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c index 2ffad3ad796..5eafc3e65a9 100644 --- a/source/blender/editors/util/undo.c +++ b/source/blender/editors/util/undo.c @@ -107,8 +107,7 @@ void ED_undo_push(bContext *C, const char *str) PE_undo_push(CTX_data_scene(C), str); } else { - if (U.uiflag & USER_GLOBALUNDO) - BKE_write_undo(C, str); + BKE_write_undo(C, str); } if (wm->file_saved) { -- cgit v1.2.3