Fix T79940 VSE Editor crash when opening a different scene as a strip
This was caused by a double lock of the DRW context mutex. This changes the logic a bit by releasing the DRW context before rendering with BKE_sequencer_give_ibuf and restoring it after. Critical fix for 2.91 Reviewed By: dfelinto Differential Revision: https://developer.blender.org/D8657
This commit is contained in:
parent
19c9b27ffe
commit
3fa1280132
Notes:
blender-bot
2023-10-12 12:49:04 +02:00
Referenced by issue #79940, VSE Editor crash when opening a different scene as a strip
|
@ -78,6 +78,7 @@ static void metadata_panel_context_draw(const bContext *C, Panel *panel)
|
|||
struct Main *bmain = CTX_data_main(C);
|
||||
struct Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C);
|
||||
struct Scene *scene = CTX_data_scene(C);
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
SpaceSeq *space_sequencer = CTX_wm_space_seq(C);
|
||||
/* NOTE: We can only reliably show metadata for the original (current)
|
||||
* frame when split view is used. */
|
||||
|
@ -88,7 +89,8 @@ static void metadata_panel_context_draw(const bContext *C, Panel *panel)
|
|||
}
|
||||
/* NOTE: We disable multiview for drawing, since we don't know what is the
|
||||
* from the panel (is kind of all the views?). */
|
||||
ImBuf *ibuf = sequencer_ibuf_get(bmain, depsgraph, scene, space_sequencer, scene->r.cfra, 0, "");
|
||||
ImBuf *ibuf = sequencer_ibuf_get(
|
||||
bmain, region, depsgraph, scene, space_sequencer, scene->r.cfra, 0, "");
|
||||
if (ibuf != NULL) {
|
||||
ED_region_image_metadata_panel_draw(ibuf, panel->layout);
|
||||
IMB_freeImBuf(ibuf);
|
||||
|
|
|
@ -1230,7 +1230,14 @@ void ED_sequencer_special_preview_clear(void)
|
|||
sequencer_special_update_set(NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rendering using opengl will change the current viewport/context.
|
||||
* This is why we need the ARegion, to set back the render area.
|
||||
* TODO do not rely on such hack and just update the ibuf ouside of
|
||||
* the UI drawing code.
|
||||
**/
|
||||
ImBuf *sequencer_ibuf_get(struct Main *bmain,
|
||||
ARegion *region,
|
||||
struct Depsgraph *depsgraph,
|
||||
Scene *scene,
|
||||
SpaceSeq *sseq,
|
||||
|
@ -1266,9 +1273,16 @@ ImBuf *sequencer_ibuf_get(struct Main *bmain,
|
|||
* by Escape pressed somewhere in the past. */
|
||||
G.is_break = false;
|
||||
|
||||
/* Rendering can change OGL context. Save & Restore framebuffer. */
|
||||
GPUViewport *viewport = WM_draw_region_get_bound_viewport(region);
|
||||
GPUFrameBuffer *fb = GPU_framebuffer_active_get();
|
||||
GPU_framebuffer_restore();
|
||||
if (viewport) {
|
||||
/* Unbind viewport to release the DRW context. */
|
||||
GPU_viewport_unbind(viewport);
|
||||
}
|
||||
else {
|
||||
/* Rendering can change OGL context. Save & Restore framebuffer. */
|
||||
GPU_framebuffer_restore();
|
||||
}
|
||||
|
||||
if (special_seq_update) {
|
||||
ibuf = BKE_sequencer_give_ibuf_direct(&context, cfra + frame_ofs, special_seq_update);
|
||||
|
@ -1277,7 +1291,12 @@ ImBuf *sequencer_ibuf_get(struct Main *bmain,
|
|||
ibuf = BKE_sequencer_give_ibuf(&context, cfra + frame_ofs, sseq->chanshown);
|
||||
}
|
||||
|
||||
if (fb) {
|
||||
if (viewport) {
|
||||
/* Follows same logic as wm_draw_window_offscreen to make sure to restore the same viewport. */
|
||||
int view = (sseq->multiview_eye == STEREO_RIGHT_ID) ? 1 : 0;
|
||||
GPU_viewport_bind(viewport, view, ®ion->winrct);
|
||||
}
|
||||
else if (fb) {
|
||||
GPU_framebuffer_bind(fb);
|
||||
}
|
||||
|
||||
|
@ -1764,9 +1783,12 @@ void sequencer_draw_preview(const bContext *C,
|
|||
return;
|
||||
}
|
||||
|
||||
/* Get image. */
|
||||
ibuf = sequencer_ibuf_get(
|
||||
bmain, region, depsgraph, scene, sseq, cfra, frame_ofs, names[sseq->multiview_eye]);
|
||||
|
||||
/* Setup offscreen buffers. */
|
||||
GPUViewport *viewport = WM_draw_region_get_viewport(region);
|
||||
|
||||
GPUFrameBuffer *framebuffer_overlay = GPU_viewport_framebuffer_overlay_get(viewport);
|
||||
GPU_framebuffer_bind_no_srgb(framebuffer_overlay);
|
||||
GPU_depth_test(GPU_DEPTH_NONE);
|
||||
|
@ -1790,12 +1812,6 @@ void sequencer_draw_preview(const bContext *C,
|
|||
imm_draw_box_checker_2d(v2d->tot.xmin, v2d->tot.ymin, v2d->tot.xmax, v2d->tot.ymax);
|
||||
}
|
||||
}
|
||||
/* Get image. */
|
||||
ibuf = sequencer_ibuf_get(
|
||||
bmain, depsgraph, scene, sseq, cfra, frame_ofs, names[sseq->multiview_eye]);
|
||||
|
||||
/* sequencer_ibuf_get can call GPU_framebuffer_bind. So disable srgb framebuffer again. */
|
||||
GPU_framebuffer_bind_no_srgb(framebuffer_overlay);
|
||||
|
||||
if (ibuf) {
|
||||
scope = sequencer_get_scope(scene, sseq, ibuf, draw_backdrop);
|
||||
|
|
|
@ -60,6 +60,7 @@ float sequence_handle_size_get_clamped(struct Sequence *seq, const float pixelx)
|
|||
/* void seq_reset_imageofs(struct SpaceSeq *sseq); */
|
||||
|
||||
struct ImBuf *sequencer_ibuf_get(struct Main *bmain,
|
||||
struct ARegion *region,
|
||||
struct Depsgraph *depsgraph,
|
||||
struct Scene *scene,
|
||||
struct SpaceSeq *sseq,
|
||||
|
|
|
@ -305,7 +305,7 @@ static void sequencer_sample_apply(bContext *C, wmOperator *op, const wmEvent *e
|
|||
Scene *scene = CTX_data_scene(C);
|
||||
SpaceSeq *sseq = (SpaceSeq *)CTX_wm_space_data(C);
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
ImBuf *ibuf = sequencer_ibuf_get(bmain, depsgraph, scene, sseq, CFRA, 0, NULL);
|
||||
ImBuf *ibuf = sequencer_ibuf_get(bmain, region, depsgraph, scene, sseq, CFRA, 0, NULL);
|
||||
ImageSampleInfo *info = op->customdata;
|
||||
float fx, fy;
|
||||
|
||||
|
|
Loading…
Reference in New Issue