From 64c15823f72c199cc30375f69cfa5a20b685dc89 Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Tue, 4 Mar 2025 09:35:27 +0100 Subject: [PATCH] Fix #135355: ops.render.opengl() in the console wont return {'FINISHED'} Caused by 40ac21e5a5 [does not remember/resore the previous ScrArea & ARegion anymore]. Without this, the operator reporting might get confused by using the wrong area/region, so added back NOTE: I tried to just notify `NC_SPACE | ND_SPACE_INFO_REPORT` in `screen_opengl_render_end` (same as in `wm_operator_finished` > `wm_operator_register`), but to no avail... Think this is quite good pratice to leave us with the original area/ region anyways though. Thx @brecht for improvements (restoring in `screen_opengl_render_init` already, also taking care of restoring in some early out cases) Co-authored-by: Brecht Van Lommel Pull Request: https://projects.blender.org/blender/blender/pulls/135394 --- .../blender/editors/render/render_opengl.cc | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/render/render_opengl.cc b/source/blender/editors/render/render_opengl.cc index c55090185e9..95e27acadf8 100644 --- a/source/blender/editors/render/render_opengl.cc +++ b/source/blender/editors/render/render_opengl.cc @@ -693,6 +693,8 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op) WorkSpace *workspace = CTX_wm_workspace(C); Scene *scene = CTX_data_scene(C); + ScrArea *prev_area = CTX_wm_area(C); + ARegion *prev_region = CTX_wm_region(C); GPUOffScreen *ofs; OGLRender *oglrender; int sizex, sizey; @@ -716,6 +718,12 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op) return false; } + if (!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.im_format.imtype)) { + BKE_report( + op->reports, RPT_ERROR, "Cannot write a single file with an animation format selected"); + return false; + } + if (is_sequencer) { is_view_context = false; } @@ -732,12 +740,6 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op) } } - if (!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.im_format.imtype)) { - BKE_report( - op->reports, RPT_ERROR, "Cannot write a single file with an animation format selected"); - return false; - } - /* stop all running jobs, except screen one. currently previews frustrate Render */ WM_jobs_kill_all_except(wm, CTX_wm_screen(C)); @@ -756,6 +758,8 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op) if (!ofs) { BKE_reportf(op->reports, RPT_ERROR, "Failed to create OpenGL off-screen buffer, %s", err_out); + CTX_wm_area_set(C, prev_area); + CTX_wm_region_set(C, prev_region); return false; } @@ -850,6 +854,9 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op) } } + CTX_wm_area_set(C, prev_area); + CTX_wm_region_set(C, prev_region); + return true; }