Fix saving images from temp Image Editor failing
Steps to reproduce were: * Ensure //Render//->//Display Mode// is //New Window// * F12 * In the opened Image Editor, Alt+S to save the image * Save the image The saving would fail silently. Issue was that wm_handler_op_context() would fail to find the correct area to activate, as the wrong window was active in context. So allow overriding this window and do so when creating the file-select handler.
This commit is contained in:
@@ -1804,8 +1804,11 @@ void wm_event_free_handler(wmEventHandler *handler)
|
|||||||
/* only set context when area/region is part of screen */
|
/* only set context when area/region is part of screen */
|
||||||
static void wm_handler_op_context(bContext *C, wmEventHandler_Op *handler, const wmEvent *event)
|
static void wm_handler_op_context(bContext *C, wmEventHandler_Op *handler, const wmEvent *event)
|
||||||
{
|
{
|
||||||
wmWindow *win = CTX_wm_window(C);
|
wmWindow *win = handler->context.win ? handler->context.win : CTX_wm_window(C);
|
||||||
bScreen *screen = CTX_wm_screen(C);
|
/* It's probably fine to always use WM_window_get_active_screen() to get the screen. But this
|
||||||
|
* code has been getting it through context since forever, so play safe and stick to that when
|
||||||
|
* possible. */
|
||||||
|
bScreen *screen = handler->context.win ? WM_window_get_active_screen(win) : CTX_wm_screen(C);
|
||||||
|
|
||||||
if (screen && handler->op) {
|
if (screen && handler->op) {
|
||||||
if (handler->context.area == NULL) {
|
if (handler->context.area == NULL) {
|
||||||
@@ -2401,6 +2404,9 @@ static int wm_handler_fileselect_do(bContext *C,
|
|||||||
* opening (UI_BLOCK_MOVEMOUSE_QUIT) */
|
* opening (UI_BLOCK_MOVEMOUSE_QUIT) */
|
||||||
wm_get_cursor_position(ctx_win, &ctx_win->eventstate->x, &ctx_win->eventstate->y);
|
wm_get_cursor_position(ctx_win, &ctx_win->eventstate->x, &ctx_win->eventstate->y);
|
||||||
wm->winactive = ctx_win; /* Reports use this... */
|
wm->winactive = ctx_win; /* Reports use this... */
|
||||||
|
if (handler->context.win == win) {
|
||||||
|
handler->context.win = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (file_sa->full) {
|
else if (file_sa->full) {
|
||||||
ED_screen_full_prevspace(C, file_sa);
|
ED_screen_full_prevspace(C, file_sa);
|
||||||
@@ -3538,6 +3544,7 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op)
|
|||||||
|
|
||||||
handler->is_fileselect = true;
|
handler->is_fileselect = true;
|
||||||
handler->op = op;
|
handler->op = op;
|
||||||
|
handler->context.win = CTX_wm_window(C);
|
||||||
handler->context.area = CTX_wm_area(C);
|
handler->context.area = CTX_wm_area(C);
|
||||||
handler->context.region = CTX_wm_region(C);
|
handler->context.region = CTX_wm_region(C);
|
||||||
|
|
||||||
|
|||||||
@@ -116,6 +116,10 @@ typedef struct wmEventHandler_Op {
|
|||||||
|
|
||||||
/** Store context for this handler for derived/modal handlers. */
|
/** Store context for this handler for derived/modal handlers. */
|
||||||
struct {
|
struct {
|
||||||
|
/* To override the window, and hence the screen. Set for few cases only, usually window/screen
|
||||||
|
* can be taken from current context. */
|
||||||
|
struct wmWindow *win;
|
||||||
|
|
||||||
struct ScrArea *area;
|
struct ScrArea *area;
|
||||||
struct ARegion *region;
|
struct ARegion *region;
|
||||||
short region_type;
|
short region_type;
|
||||||
|
|||||||
Reference in New Issue
Block a user