Fix T56418: Changing to Solid View crashes Blender

Everything seems to behave like it should when drawdata is alloced
on instances.
This commit is contained in:
Clément Foucault 2018-08-16 23:55:11 +02:00
parent 7d29c9a16b
commit 1e26345a89
Notes: blender-bot 2023-02-14 05:25:48 +01:00
Referenced by commit d67c86d42a, Revert "Fix T56418: Changing to Solid View crashes Blender"
Referenced by issue #56418, Changing to Solid View crashes Blender
1 changed files with 1 additions and 17 deletions

View File

@ -834,23 +834,7 @@ DrawData *DRW_drawdata_ensure(
DrawDataList *drawdata = DRW_drawdatalist_from_id(id);
/* Allocate new data. */
if ((GS(id->name) == ID_OB) && (((Object *)id)->base_flag & BASE_FROMDUPLI) != 0) {
/* NOTE: data is not persistent in this case. It is reset each redraw. */
BLI_assert(free_cb == NULL); /* No callback allowed. */
/* Round to sizeof(float) for DRW_instance_data_request(). */
const size_t t = sizeof(float) - 1;
size = (size + t) & ~t;
size_t fsize = size / sizeof(float);
BLI_assert(fsize < MAX_INSTANCE_DATA_SIZE);
if (DST.object_instance_data[fsize] == NULL) {
DST.object_instance_data[fsize] = DRW_instance_data_request(DST.idatalist, fsize);
}
dd = (DrawData *)DRW_instance_data_next(DST.object_instance_data[fsize]);
memset(dd, 0, size);
}
else {
dd = MEM_callocN(size, "DrawData");
}
dd = MEM_callocN(size, "DrawData");
dd->engine_type = engine_type;
dd->free = free_cb;
/* Perform user-side initialization, if needed. */