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:
authorClément Foucault <foucault.clem@gmail.com>2018-08-22 14:41:18 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-08-22 14:51:03 +0300
commitddc09790d87f078258743477f6372b675a72b7f6 (patch)
tree552d048e9629730afc7219a71decb1f82eac6def /source/blender/draw/intern
parentd67c86d42a5c563c939fbc5b5df66751ae6023e4 (diff)
DRW: Fix T56418 and T56474 in a more robust way
Diffstat (limited to 'source/blender/draw/intern')
-rw-r--r--source/blender/draw/intern/draw_manager.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 57ddaa1e16f..b203cbea69e 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -881,6 +881,19 @@ void DRW_drawdata_free(ID *id)
BLI_freelistN((ListBase *)drawdata);
}
+/* Unlink (but don't free) the drawdata from the DrawDataList if the ID is an OB from dupli. */
+static void drw_drawdata_unlink_dupli(ID *id)
+{
+ if ((GS(id->name) == ID_OB) && (((Object *)id)->base_flag & BASE_FROMDUPLI) != 0) {
+ DrawDataList *drawdata = DRW_drawdatalist_from_id(id);
+
+ if (drawdata == NULL)
+ return;
+
+ BLI_listbase_clear((ListBase *)drawdata);
+ }
+}
+
/** \} */
@@ -944,6 +957,12 @@ static void drw_engines_cache_populate(Object *ob)
{
DST.ob_state = NULL;
+ /* HACK: DrawData is copied by COW from the duplicated object.
+ * This is valid for IDs that cannot be instanciated but this
+ * is not what we want in this case so we clear the pointer
+ * ourselves here. */
+ drw_drawdata_unlink_dupli((ID *)ob);
+
for (LinkData *link = DST.enabled_engines.first; link; link = link->next) {
DrawEngineType *engine = link->data;
ViewportEngineData *data = drw_viewport_engine_data_ensure(engine);
@@ -956,6 +975,10 @@ static void drw_engines_cache_populate(Object *ob)
engine->cache_populate(data, ob);
}
}
+
+ /* ... and clearing it here too because theses draw data are
+ * from a mempool and must not be free individually by depsgraph. */
+ drw_drawdata_unlink_dupli((ID *)ob);
}
static void drw_engines_cache_finish(void)