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
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2018-10-17 17:43:02 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-10-17 17:43:02 +0300
commit5f8222501c2267ae82829ccf6f6df295a8b8ec55 (patch)
tree4ae7d41d29e7ede31fd82b8c91a6dcecff8123df /source/blender/editors/undo
parent496c325ffa84cec631c8e45723decbb90037156a (diff)
DEBUG_IO: add sanity check on libdata in undo step as well.
There are serious suspicions that weird corruptions faced by studio artists may happen in undo/redo code, so let's see whether that's the case. With this, and when --debug-io arg is passed on startup, the whole lib data are checked at every undo. This makes undo slower (from two to three times slower), but it could help us spot better what happens...
Diffstat (limited to 'source/blender/editors/undo')
-rw-r--r--source/blender/editors/undo/CMakeLists.txt1
-rw-r--r--source/blender/editors/undo/ed_undo.c35
2 files changed, 28 insertions, 8 deletions
diff --git a/source/blender/editors/undo/CMakeLists.txt b/source/blender/editors/undo/CMakeLists.txt
index 89832604ed8..2e3e73f34f4 100644
--- a/source/blender/editors/undo/CMakeLists.txt
+++ b/source/blender/editors/undo/CMakeLists.txt
@@ -22,6 +22,7 @@ set(INC
../include
../../blenkernel
../../blenlib
+ ../../blenloader
../../blentranslation
../../makesdna
../../makesrna
diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c
index e0a1faf04b8..c69fabdbd70 100644
--- a/source/blender/editors/undo/ed_undo.c
+++ b/source/blender/editors/undo/ed_undo.c
@@ -47,9 +47,12 @@
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_main.h"
+#include "BKE_report.h"
#include "BKE_screen.h"
#include "BKE_undo_system.h"
+#include "BLO_runtime.h"
+
#include "ED_gpencil.h"
#include "ED_render.h"
#include "ED_screen.h"
@@ -101,7 +104,7 @@ void ED_undo_push(bContext *C, const char *str)
}
/* note: also check undo_history_exec() in bottom if you change notifiers */
-static int ed_undo_step(bContext *C, int step, const char *undoname)
+static int ed_undo_step(bContext *C, int step, const char *undoname, ReportList *reports)
{
CLOG_INFO(&LOG, 1, "name='%s', step=%d", undoname, step);
wmWindowManager *wm = CTX_wm_manager(C);
@@ -111,6 +114,14 @@ static int ed_undo_step(bContext *C, int step, const char *undoname)
* or they can just lead to freezing job in some other cases */
WM_jobs_kill_all(wm);
+ if (G.debug & G_DEBUG_IO) {
+ Main *bmain = CTX_data_main(C);
+ if (bmain->lock != NULL) {
+ BKE_report(reports, RPT_INFO, "Checking sanity of current .blend file *BEFORE* undo step.");
+ BLO_main_validate_libraries(bmain, reports);
+ }
+ }
+
/* TODO(campbell): undo_system: use undo system */
/* grease pencil can be can be used in plenty of spaces, so check it first */
if (ED_gpencil_session_active()) {
@@ -161,6 +172,14 @@ static int ed_undo_step(bContext *C, int step, const char *undoname)
wm->op_undo_depth--;
}
+ if (G.debug & G_DEBUG_IO) {
+ Main *bmain = CTX_data_main(C);
+ if (bmain->lock != NULL) {
+ BKE_report(reports, RPT_INFO, "Checking sanity of current .blend file *AFTER* undo step.");
+ BLO_main_validate_libraries(bmain, reports);
+ }
+ }
+
WM_event_add_notifier(C, NC_WINDOW, NULL);
WM_event_add_notifier(C, NC_WM | ND_UNDO, NULL);
@@ -182,11 +201,11 @@ void ED_undo_grouped_push(bContext *C, const char *str)
void ED_undo_pop(bContext *C)
{
- ed_undo_step(C, 1, NULL);
+ ed_undo_step(C, 1, NULL, NULL);
}
void ED_undo_redo(bContext *C)
{
- ed_undo_step(C, -1, NULL);
+ ed_undo_step(C, -1, NULL, NULL);
}
void ED_undo_push_op(bContext *C, wmOperator *op)
@@ -208,7 +227,7 @@ void ED_undo_grouped_push_op(bContext *C, wmOperator *op)
void ED_undo_pop_op(bContext *C, wmOperator *op)
{
/* search back a couple of undo's, in case something else added pushes */
- ed_undo_step(C, 0, op->type->name);
+ ed_undo_step(C, 0, op->type->name, op->reports);
}
/* name optionally, function used to check for operator redo panel */
@@ -237,11 +256,11 @@ UndoStack *ED_undo_stack_get(void)
/** \name Undo, Undo Push & Redo Operators
* \{ */
-static int ed_undo_exec(bContext *C, wmOperator *UNUSED(op))
+static int ed_undo_exec(bContext *C, wmOperator *op)
{
/* "last operator" should disappear, later we can tie this with undo stack nicer */
WM_operator_stack_clear(CTX_wm_manager(C));
- int ret = ed_undo_step(C, 1, NULL);
+ int ret = ed_undo_step(C, 1, NULL, op->reports);
if (ret & OPERATOR_FINISHED) {
/* Keep button under the cursor active. */
WM_event_add_mousemove(C);
@@ -257,9 +276,9 @@ static int ed_undo_push_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-static int ed_redo_exec(bContext *C, wmOperator *UNUSED(op))
+static int ed_redo_exec(bContext *C, wmOperator *op)
{
- int ret = ed_undo_step(C, -1, NULL);
+ int ret = ed_undo_step(C, -1, NULL, op->reports);
if (ret & OPERATOR_FINISHED) {
/* Keep button under the cursor active. */
WM_event_add_mousemove(C);