diff options
Diffstat (limited to 'source/blender/editors/undo/ed_undo.c')
-rw-r--r-- | source/blender/editors/undo/ed_undo.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c index d8b194e3336..0b77006afb7 100644 --- a/source/blender/editors/undo/ed_undo.c +++ b/source/blender/editors/undo/ed_undo.c @@ -36,6 +36,7 @@ #include "CLG_log.h" #include "DNA_scene_types.h" +#include "DNA_object_types.h" #include "BLI_utildefines.h" @@ -46,6 +47,7 @@ #include "BKE_global.h" #include "BKE_main.h" #include "BKE_screen.h" +#include "BKE_layer.h" #include "BKE_undo_system.h" #include "ED_gpencil.h" @@ -495,3 +497,24 @@ void ED_OT_undo_history(wmOperatorType *ot) } /** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Undo Helper Functions + * \{ */ + +void ED_undo_object_set_active_or_warn(ViewLayer *view_layer, Object *ob, const char *info, CLG_LogRef *log) +{ + Object *ob_prev = OBACT(view_layer); + if (ob_prev != ob) { + Base *base = BKE_view_layer_base_find(view_layer, ob); + if (base != NULL) { + view_layer->basact = base; + } + else { + /* Should never fail, may not crash but can give odd behavior. */ + CLOG_WARN(log, "'%s' failed to restore active object: '%s'", info, ob->id.name + 2); + } + } +} + +/** \} */ |