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:
authorSergey Sharybin <sergey.vfx@gmail.com>2019-07-25 17:36:22 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2019-07-31 17:55:15 +0300
commit3566b81c8bfa8c69d542a5de29ecb8d5af3ccb3d (patch)
tree8c549ae6f2b1064399a7c0b99ab6ce9b287bdd28 /source/blender/editors/curve
parentf5f3003874f26681000618032d88482367348064 (diff)
Refactor access to dependency graph
This change ensures that operators which needs access to evaluated data first makes sure there is a dependency graph. Other accesses to the dependency graph made it more explicit about whether they just need a valid dependency graph pointer or whether they expect the graph to be already evaluated. This replaces OPTYPE_USE_EVAL_DATA which is now removed. Some general rules about usage of accessors: - Drawing is expected to happen from a fully evaluated dependency graph. There is now a function to access it, which will in the future control that dependency graph is actually evaluated. This check is not yet done because there are some things to be taken care about first: for example, post-update hooks might leave scene in a state where something is still tagged for update. - All operators which needs to access evaluated state must use CTX_data_ensure_evaluated_depsgraph(). This function replaces OPTYPE_USE_EVAL_DATA. The call is generally to be done in the very beginning of the operator, prior other logic (unless this is some comprehensive operator which might or might not need access to an evaluated state). This call is never to be used from a loop. If some utility function requires evaluated state of dependency graph the graph is to be passed as an explicit argument. This way it is clear that no evaluation happens in a loop or something like this. - All cases which needs to know dependency graph pointer, but which doesn't want to actually evaluate it can use old-style function CTX_data_depsgraph_pointer(), assuming that underlying code will ensure dependency graph is evaluated prior to accessing it. - The new functions are replacing OPTYPE_USE_EVAL_DATA, so now it is explicit and local about where dependency graph is being ensured. This commit also contains some fixes of wrong usage of evaluation functions on original objects. Ideally should be split out, but in reality with all the APIs being renamed is quite tricky. Fixes T67454: Blender crash on rapid undo and select Speculation here is that sometimes undo and selection operators are sometimes handled in the same event loop iteration, which leaves non-evaluated dependency graph. Fixes T67973: Crash on Fix Deforms operator Fixes T67902: Crash when undo a loop cut Reviewers: brecht Reviewed By: brecht Subscribers: lichtwerk Maniphest Tasks: T67454 Differential Revision: https://developer.blender.org/D5343
Diffstat (limited to 'source/blender/editors/curve')
-rw-r--r--source/blender/editors/curve/editcurve.c11
-rw-r--r--source/blender/editors/curve/editcurve_paint.c2
-rw-r--r--source/blender/editors/curve/editfont.c6
3 files changed, 10 insertions, 9 deletions
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index d1d43a49826..047b78af7b1 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -7094,16 +7094,17 @@ static bool match_texture_space_poll(bContext *C)
static int match_texture_space_exec(bContext *C, wmOperator *UNUSED(op))
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
- Scene *scene = CTX_data_scene(C);
+ /* Need to ensure the dependency graph is fully evaluated, so the display list is at a correct
+ * state. */
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
+ (void)depsgraph;
+
Object *object = CTX_data_active_object(C);
Curve *curve = (Curve *)object->data;
float min[3], max[3], size[3], loc[3];
int a;
- if (object->runtime.curve_cache == NULL) {
- BKE_displist_make_curveTypes(depsgraph, scene, object, false, false);
- }
+ BLI_assert(object->runtime.curve_cache != NULL);
INIT_MINMAX(min, max);
BKE_displist_minmax(&object->runtime.curve_cache->disp, min, max);
diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c
index 9debea7bf88..5e0053782d4 100644
--- a/source/blender/editors/curve/editcurve_paint.c
+++ b/source/blender/editors/curve/editcurve_paint.c
@@ -586,7 +586,7 @@ static bool curve_draw_init(bContext *C, wmOperator *op, bool is_invoke)
}
else {
cdd->vc.bmain = CTX_data_main(C);
- cdd->vc.depsgraph = CTX_data_depsgraph(C);
+ cdd->vc.depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
cdd->vc.scene = CTX_data_scene(C);
cdd->vc.view_layer = CTX_data_view_layer(C);
cdd->vc.obedit = CTX_data_edit_object(C);
diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c
index db3d5ad401d..c912cea5937 100644
--- a/source/blender/editors/curve/editfont.c
+++ b/source/blender/editors/curve/editfont.c
@@ -407,7 +407,6 @@ static int insert_into_textbuf(Object *obedit, uintptr_t c)
static void text_update_edited(bContext *C, Object *obedit, int mode)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
Curve *cu = obedit->data;
EditFont *ef = cu->editfont;
@@ -421,6 +420,7 @@ static void text_update_edited(bContext *C, Object *obedit, int mode)
else {
/* depsgraph runs above, but since we're not tagging for update, call direct */
/* We need evaluated data here. */
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
BKE_vfont_to_curve(DEG_get_evaluated_object(depsgraph, obedit), mode);
}
@@ -590,7 +590,7 @@ void FONT_OT_text_paste_from_file(wmOperatorType *ot)
static void txt_add_object(bContext *C, TextLine *firstline, int totline, const float offset[3])
{
Main *bmain = CTX_data_main(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Curve *cu;
@@ -1084,7 +1084,7 @@ static const EnumPropertyItem move_type_items[] = {
static int move_cursor(bContext *C, int type, const bool select)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Object *obedit = CTX_data_edit_object(C);
Curve *cu = obedit->data;
EditFont *ef = cu->editfont;