Merge branch 'master' into blender2.8
authorCampbell Barton <ideasman42@gmail.com>
Fri, 13 Jul 2018 16:04:41 +0000 (18:04 +0200)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 13 Jul 2018 16:04:41 +0000 (18:04 +0200)
1  2 
source/blender/editors/undo/ed_undo.c

index b604b1db56f0c4a7593d41195a5c8bbb94c3af45,a13fa4af4e2df54ff1cc933e5a6c26d1fcf982eb..1459214957916e246118bcfad5ea01bd53377cd9
@@@ -36,7 -36,6 +36,7 @@@
  #include "CLG_log.h"
  
  #include "DNA_scene_types.h"
 +#include "DNA_object_types.h"
  
  #include "BLI_utildefines.h"
  #include "BLI_callbacks.h"
@@@ -49,7 -48,6 +49,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"
@@@ -59,7 -57,6 +59,7 @@@
  
  #include "WM_api.h"
  #include "WM_types.h"
 +#include "WM_toolsystem.h"
  
  #include "RNA_access.h"
  #include "RNA_define.h"
@@@ -109,6 -106,7 +109,6 @@@ static int ed_undo_step(bContext *C, in
        CLOG_INFO(&LOG, 1, "name='%s', step=%d", undoname, step);
        wmWindowManager *wm = CTX_wm_manager(C);
        wmWindow *win = CTX_wm_window(C);
 -      // Main *bmain = CTX_data_main(C);
        Scene *scene = CTX_data_scene(C);
  
        /* undo during jobs are running can easily lead to freeing data using by jobs,
                        return OPERATOR_CANCELLED;
                }
  
-               /* happens on redo. */
-               // BLI_assert(step_data_from_name != wm->undo_stack->step_active);
-               /* TODO(campbell): could use simple optimization. */
+               /* TODO(campbell), could use simple optimization. */
+               /* Pointers match on redo. */
                step_for_callback = (
                        BLI_findindex(&wm->undo_stack->steps, step_data_from_name) <
                        BLI_findindex(&wm->undo_stack->steps, wm->undo_stack->step_active)) ? 1 : -1;
        WM_event_add_notifier(C, NC_WINDOW, NULL);
        WM_event_add_notifier(C, NC_WM | ND_UNDO, NULL);
  
 +      Main *bmain = CTX_data_main(C);
 +      WM_toolsystem_refresh_screen_all(bmain);
 +
        if (win) {
                win->addmousemove = true;
        }
@@@ -343,7 -337,7 +342,7 @@@ void ED_OT_undo_redo(wmOperatorType *ot
   * \{ */
  
  /* ui callbacks should call this rather than calling WM_operator_repeat() themselves */
 -int ED_undo_operator_repeat(bContext *C, struct wmOperator *op)
 +int ED_undo_operator_repeat(bContext *C, wmOperator *op)
  {
        int ret = 0;
  
                struct Scene *scene = CTX_data_scene(C);
  
                /* keep in sync with logic in view3d_panel_operator_redo() */
 -              ARegion *ar = CTX_wm_region(C);
 -              ARegion *ar1 = BKE_area_find_region_active_win(CTX_wm_area(C));
 +              ARegion *ar_orig = CTX_wm_region(C);
 +              ARegion *ar_win = BKE_area_find_region_active_win(CTX_wm_area(C));
  
 -              if (ar1)
 -                      CTX_wm_region_set(C, ar1);
 +              if (ar_win) {
 +                      CTX_wm_region_set(C, ar_win);
 +              }
  
                if ((WM_operator_repeat_check(C, op)) &&
                    (WM_operator_poll(C, op->type)) &&
                {
                        int retval;
  
 -                      ED_viewport_render_kill_jobs(wm, CTX_data_main(C), true);
 -
                        if (G.debug & G_DEBUG)
                                printf("redo_cb: operator redo %s\n", op->type->name);
  
                }
  
                /* set region back */
 -              CTX_wm_region_set(C, ar);
 +              CTX_wm_region_set(C, ar_orig);
        }
        else {
                CLOG_WARN(&LOG, "called with NULL 'op'");
@@@ -447,7 -442,7 +446,7 @@@ static const EnumPropertyItem *rna_undo
                        item_tmp.identifier = us->name;
                        item_tmp.name = IFACE_(us->name);
                        if (us == wm->undo_stack->step_active) {
 -                              item_tmp.icon = ICON_RESTRICT_VIEW_OFF;
 +                              item_tmp.icon = ICON_HIDE_OFF;
                        }
                        else {
                                item_tmp.icon = ICON_NONE;
@@@ -530,24 -525,3 +529,24 @@@ void ED_OT_undo_history(wmOperatorType 
  }
  
  /** \} */
 +
 +/* -------------------------------------------------------------------- */
 +/** \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);
 +              }
 +      }
 +}
 +
 +/** \} */