[Bf-blender-cvs] [84320976692] greasepencil-object: Fix crash on trying to save files with GP objects
Joshua Leung
noreply at git.blender.org
Sat Nov 4 12:23:15 CET 2017
Commit: 84320976692e1e933b0159b6f3ab15eb6acde583
Author: Joshua Leung
Date: Sun Nov 5 00:23:02 2017 +1300
Branches: greasepencil-object
https://developer.blender.org/rB84320976692e1e933b0159b6f3ab15eb6acde583
Fix crash on trying to save files with GP objects
Quick fix for context being NULL when the thumbnail renderer gets triggered
while trying to save files.
TODO: We need a better solution here for passing eval_ctx down to GP modifiers
===================================================================
M source/blender/blenlib/intern/listbase.c
M source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
===================================================================
diff --git a/source/blender/blenlib/intern/listbase.c b/source/blender/blenlib/intern/listbase.c
index 0a6d575c7d6..4bfc5218d71 100644
--- a/source/blender/blenlib/intern/listbase.c
+++ b/source/blender/blenlib/intern/listbase.c
@@ -576,6 +576,9 @@ void *BLI_findstring(const ListBase *listbase, const char *id, const int offset)
Link *link = NULL;
const char *id_iter;
+ if (id == NULL)
+ return NULL;
+
for (link = listbase->first; link; link = link->next) {
id_iter = ((const char *)link) + offset;
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index 19660781068..4493f830a71 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -672,8 +672,14 @@ static void gpencil_draw_strokes(GpencilBatchCache *cache, GPENCIL_e_data *e_dat
/* Get evaluation context */
const DRWContextState *draw_ctx = DRW_context_state_get();
const bContext *C = draw_ctx->evil_C;
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
+
+ EvaluationContext eval_ctx = {0};
+ if (C) {
+ /* NOTE: We must check if C is valid, otherwise we get crashes when trying to save files
+ * (i.e. the thumbnail offscreen rendering fails)
+ */
+ CTX_data_eval_ctx(C, &eval_ctx);
+ }
/* get parent matrix and save as static data */
ED_gpencil_parent_location(ob, gpd, gpl, viewmatrix);
More information about the Bf-blender-cvs
mailing list