Page MenuHome

Fix initialization of the workbench engine when rendering
AbandonedPublic

Authored by Robert Guetzkow (rjg) on Apr 19 2020, 6:51 PM.

Details

Summary

The change introduced in rBa250be980a13d487099873bb5edf9c797b701ca1 causes a crash when rendering an image or animation with the workbench engine as reported in T75902. The cause is that v3d is only set when using viewport rendering, but not when rendering a still image. When v3d is NULL this resulted in a crash due to null pointer dereferencing in the CULL_BACKFACE_ENABLED macro.

The proposed fix is to use wpd when v3d is NULL.

Diff Detail

Repository
rB Blender
Branch
2020-04-19-fix-workbench-init (branched from master)
Build Status
Buildable 7628
Build 7628: arc lint + arc unit

Event Timeline

Robert Guetzkow (rjg) requested review of this revision.Apr 19 2020, 6:51 PM

Perhaps a more elegant patch with less repetition would be:

bool cull_backface = v3d ? CULL_BACKFACE_ENABLED(v3d) : CULL_BACKFACE_ENABLED(wpd);
wpd->cull_state = cull_backface ? DRW_STATE_CULL_BACK : 0;
Jeroen Bakker (jbakker) added inline comments.
source/blender/draw/engines/workbench/workbench_data.c
203

Can't we just always use wpd. the macro was created to work on wpd.

@Jeroen Bakker (jbakker) Apparently not, since @Clément Foucault (fclem) introduced this change in rBa250be980a13d487099873bb5edf9c797b701ca1 to fix T74805. Previously it did only use wpd.

I fixed it in a more correct way.