[Bf-blender-cvs] [7a005fb7d17] blender-v2.92-release: Fix T84324: Crash when combining two scenes in compositor.

Jeroen Bakker noreply at git.blender.org
Mon Jan 25 12:46:35 CET 2021


Commit: 7a005fb7d172ba73936ad263aabd2ed7e4392688
Author: Jeroen Bakker
Date:   Mon Jan 25 12:44:18 2021 +0100
Branches: blender-v2.92-release
https://developer.blender.org/rB7a005fb7d172ba73936ad263aabd2ed7e4392688

Fix T84324: Crash when combining two scenes in compositor.

In the CompositorOperation::deinitExecution the viewer could be freed at
the same time it was drawn in the image editor or node editor. There is
a guard for that but wasn't added during the migration of the two
editors to the draw manager.

===================================================================

M	source/blender/editors/space_image/space_image.c
M	source/blender/editors/space_node/drawnode.c

===================================================================

diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index d504bfbe276..776fa34d1c4 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -639,6 +639,8 @@ static void image_main_region_draw(const bContext *C, ARegion *region)
   Mask *mask = NULL;
   Scene *scene = CTX_data_scene(C);
   View2D *v2d = &region->v2d;
+  Image *image = ED_space_image(sima);
+  const bool show_viewer = (image && image->source == IMA_SRC_VIEWER);
 
   /* XXX not supported yet, disabling for now */
   scene->r.scemode &= ~R_COMP_CROP;
@@ -653,8 +655,14 @@ static void image_main_region_draw(const bContext *C, ARegion *region)
     mask = ED_space_image_get_mask(sima);
   }
 
-  /* we draw image in pixelspace */
+  if (show_viewer) {
+    BLI_thread_lock(LOCK_DRAW_IMAGE);
+  }
   DRW_draw_view(C);
+  if (show_viewer) {
+    BLI_thread_unlock(LOCK_DRAW_IMAGE);
+  }
+
   draw_image_main_helpers(C, region);
 
   /* Draw Meta data of the image isn't added to the DrawManager as it is
@@ -682,12 +690,9 @@ static void image_main_region_draw(const bContext *C, ARegion *region)
   UI_view2d_view_restore(C);
 
   if (mask) {
-    Image *image = ED_space_image(sima);
-    int width, height, show_viewer;
+    int width, height;
     float aspx, aspy;
 
-    show_viewer = (image && image->source == IMA_SRC_VIEWER);
-
     if (show_viewer) {
       /* ED_space_image_get* will acquire image buffer which requires
        * lock here by the same reason why lock is needed in draw_image_main
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index df29950bc59..f2ee94af9b3 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -25,6 +25,7 @@
 #include "BLI_blenlib.h"
 #include "BLI_math.h"
 #include "BLI_system.h"
+#include "BLI_threads.h"
 
 #include "DNA_node_types.h"
 #include "DNA_object_types.h"
@@ -3770,7 +3771,9 @@ void draw_nodespace_back_pix(const bContext *C,
   /* The draw manager is used to draw the backdrop image. */
   GPUFrameBuffer *old_fb = GPU_framebuffer_active_get();
   GPU_framebuffer_restore();
+  BLI_thread_lock(LOCK_DRAW_IMAGE);
   DRW_draw_view(C);
+  BLI_thread_unlock(LOCK_DRAW_IMAGE);
   GPU_framebuffer_bind_no_srgb(old_fb);
   /* Draw manager changes the depth state. Set it back to NONE. Without this the node preview
    * images aren't drawn correctly. */



More information about the Bf-blender-cvs mailing list