DRW: Fix multithreading conflict with material previews.
authorClément Foucault <foucault.clem@gmail.com>
Tue, 27 Feb 2018 14:50:34 +0000 (15:50 +0100)
committerClément Foucault <foucault.clem@gmail.com>
Tue, 27 Feb 2018 14:50:34 +0000 (15:50 +0100)
source/blender/draw/intern/draw_manager.c

index d9c564fd1370d69a239704fd76fe16864bae54f7..dafd16be2707bbe2adfde09c8c57e08b8953a767 100644 (file)
@@ -3376,6 +3376,10 @@ void DRW_notify_view_update(const DRWUpdateContext *update_ctx)
                return;
        }
 
+       /* XXX Really nasty locking. But else this could
+        * be executed by the material previews thread
+        * while rendering a viewport. */
+       BLI_mutex_lock(&g_ogl_context_mutex);
 
        /* Reset before using it. */
        memset(&DST, 0x0, sizeof(DST));
@@ -3400,6 +3404,8 @@ void DRW_notify_view_update(const DRWUpdateContext *update_ctx)
        DST.viewport = NULL;
 
        drw_engines_disable();
+
+       BLI_mutex_unlock(&g_ogl_context_mutex);
 }
 
 /** \} */