Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-01-31 04:01:38 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-01-31 04:07:13 +0300
commit8c89790674901748cf04771dc2c5453815db1607 (patch)
tree1080bd2f35fe1d9260b63efb9e12f31a9b152835 /source
parent51bba03b319319d59f739673c3fafb71bc308e0d (diff)
Fix T60660: Texture paint undo removes image
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/include/ED_util.h1
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_undo.c6
-rw-r--r--source/blender/editors/undo/memfile_undo.c4
-rw-r--r--source/blender/editors/util/ed_util.c19
4 files changed, 29 insertions, 1 deletions
diff --git a/source/blender/editors/include/ED_util.h b/source/blender/editors/include/ED_util.h
index 390398262f9..69699a079a0 100644
--- a/source/blender/editors/include/ED_util.h
+++ b/source/blender/editors/include/ED_util.h
@@ -38,6 +38,7 @@ struct bContext;
struct wmOperatorType;
/* ed_util.c */
+void ED_editors_init_for_undo(struct Main *bmain);
void ED_editors_init(struct bContext *C);
void ED_editors_exit(struct Main *bmain, bool do_undo_system);
bool ED_editors_flush_edits(struct Main *bmain, bool for_render);
diff --git a/source/blender/editors/sculpt_paint/paint_image_undo.c b/source/blender/editors/sculpt_paint/paint_image_undo.c
index b049e613b86..25f5d91a928 100644
--- a/source/blender/editors/sculpt_paint/paint_image_undo.c
+++ b/source/blender/editors/sculpt_paint/paint_image_undo.c
@@ -46,6 +46,7 @@
#include "ED_paint.h"
#include "ED_undo.h"
+#include "ED_util.h"
#include "GPU_draw.h"
@@ -466,13 +467,16 @@ static bool image_undosys_step_encode(struct bContext *UNUSED(C), struct Main *U
return true;
}
-static void image_undosys_step_decode(struct bContext *UNUSED(C), struct Main *UNUSED(bmain), UndoStep *us_p, int UNUSED(dir))
+static void image_undosys_step_decode(struct bContext *UNUSED(C), struct Main *bmain, UndoStep *us_p, int UNUSED(dir))
{
ImageUndoStep *us = (ImageUndoStep *)us_p;
#if 0
paint_undosys_step_decode_restore_ids(us);
#endif
image_undo_restore_list(&us->tiles, us->id_map);
+
+ /* Refresh texture slots. */
+ ED_editors_init_for_undo(bmain);
}
static void image_undosys_step_free(UndoStep *us_p)
diff --git a/source/blender/editors/undo/memfile_undo.c b/source/blender/editors/undo/memfile_undo.c
index dc1870c2d19..0180b3dde81 100644
--- a/source/blender/editors/undo/memfile_undo.c
+++ b/source/blender/editors/undo/memfile_undo.c
@@ -93,6 +93,10 @@ static void memfile_undosys_step_decode(struct bContext *C, struct Main *bmain,
MemFileUndoStep *us = (MemFileUndoStep *)us_p;
BKE_memfile_undo_decode(us->data, C);
+ /* bmain has been freed. */
+ bmain = CTX_data_main(C);
+ ED_editors_init_for_undo(bmain);
+
WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, CTX_data_scene(C));
}
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index 1d56ef24403..ad07f8c6a8f 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -59,6 +59,7 @@
#include "BKE_screen.h"
#include "BKE_undo_system.h"
#include "BKE_workspace.h"
+#include "BKE_material.h"
#include "ED_armature.h"
#include "ED_buttons.h"
@@ -85,6 +86,24 @@
/* ********* general editor util funcs, not BKE stuff please! ********* */
+void ED_editors_init_for_undo(Main *bmain)
+{
+ wmWindowManager *wm = bmain->wm.first;
+ for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ ViewLayer *view_layer = WM_window_get_active_view_layer(win);
+ Base *base = BASACT(view_layer);
+ if (base != NULL) {
+ Object *ob = base->object;
+ if (ob->mode & OB_MODE_TEXTURE_PAINT) {
+ Scene *scene = WM_window_get_active_scene(win);
+
+ BKE_texpaint_slots_refresh_object(scene, ob);
+ BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
+ }
+ }
+ }
+}
+
void ED_editors_init(bContext *C)
{
struct Depsgraph *depsgraph = CTX_data_depsgraph(C);