Fix issues with confirmation prompt on Windows
* Pressing "OK" wouldn't close Blender anymore * Using File -> Quit would use popup version, not OS native window Cleaned up code a bit to avoid duplicated logic.
This commit is contained in:
parent
aeec19d2e7
commit
529c21acc2
|
@ -2162,15 +2162,7 @@ static void WM_OT_window_fullscreen_toggle(wmOperatorType *ot)
|
|||
|
||||
static int wm_exit_blender_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
|
||||
if ((U.uiflag & USER_QUIT_PROMPT) && !wm->file_saved) {
|
||||
wm_confirm_quit(C);
|
||||
}
|
||||
else {
|
||||
wm_exit_schedule_delayed(C);
|
||||
}
|
||||
|
||||
wm_quit_with_optional_confirmation_prompt(C, CTX_wm_window(C));
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
|
|
|
@ -400,18 +400,46 @@ static uiBlock *block_create_confirm_quit(struct bContext *C, struct ARegion *ar
|
|||
}
|
||||
|
||||
|
||||
/** Call the confirm dialog on quitting. */
|
||||
void wm_confirm_quit(bContext *C)
|
||||
/**
|
||||
* Call the confirm dialog on quitting. It's displayed in the context window so
|
||||
* caller should set it as desired.
|
||||
*/
|
||||
static void wm_confirm_quit(bContext *C)
|
||||
{
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
|
||||
if (GHOST_SupportsNativeDialogs() == 0) {
|
||||
UI_popup_block_invoke(C, block_create_confirm_quit, NULL);
|
||||
}
|
||||
else if (GHOST_confirmQuit(win->ghostwin)) {
|
||||
wm_exit_schedule_delayed(C);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call the quit confirmation prompt or exit directly if needed. The use can
|
||||
* still cancel via the confirmation popup. Also, this may not quit Blender
|
||||
* immediately, but rather schedule the closing.
|
||||
*
|
||||
* \param win The window to show the confirmation popup/window in.
|
||||
*/
|
||||
void wm_quit_with_optional_confirmation_prompt(bContext *C, wmWindow *win)
|
||||
{
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
wmWindow *win_ctx = CTX_wm_window(C);
|
||||
|
||||
/* The popup needs to have a window set in context to show up since
|
||||
* it's being called outside the normal operator event handling loop */
|
||||
if (wm->winactive) {
|
||||
CTX_wm_window_set(C, wm->winactive);
|
||||
/* The popup will be displayed in the context window which may not be set
|
||||
* here (this function gets called outside of normal event handling loop). */
|
||||
CTX_wm_window_set(C, win);
|
||||
|
||||
if ((U.uiflag & USER_QUIT_PROMPT) && !wm->file_saved && !G.background) {
|
||||
wm_confirm_quit(C);
|
||||
}
|
||||
else {
|
||||
wm_exit_schedule_delayed(C);
|
||||
}
|
||||
|
||||
UI_popup_block_invoke(C, block_create_confirm_quit, NULL);
|
||||
CTX_wm_window_set(C, win_ctx);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
@ -420,7 +448,6 @@ void wm_confirm_quit(bContext *C)
|
|||
void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win)
|
||||
{
|
||||
wmWindow *tmpwin;
|
||||
bool do_exit = false;
|
||||
|
||||
/* first check if we have to quit (there are non-temp remaining windows) */
|
||||
for (tmpwin = wm->windows.first; tmpwin; tmpwin = tmpwin->next) {
|
||||
|
@ -430,23 +457,8 @@ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win)
|
|||
break;
|
||||
}
|
||||
|
||||
if (tmpwin == NULL)
|
||||
do_exit = 1;
|
||||
|
||||
if ((U.uiflag & USER_QUIT_PROMPT) && !wm->file_saved && !G.background && do_exit) {
|
||||
/* We have unsaved changes and we're quitting */
|
||||
if(GHOST_SupportsNativeDialogs() == 0) {
|
||||
wm_confirm_quit(C);
|
||||
}
|
||||
else {
|
||||
if (!GHOST_confirmQuit(win->ghostwin))
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (do_exit) {
|
||||
/* No changes but we're quitting */
|
||||
/* let WM_exit do all freeing, for correct quit.blend save */
|
||||
WM_exit(C);
|
||||
if (tmpwin == NULL) {
|
||||
wm_quit_with_optional_confirmation_prompt(C, win);
|
||||
}
|
||||
else {
|
||||
/* We're just closing a window */
|
||||
|
|
|
@ -78,7 +78,7 @@ void wm_window_IME_end (wmWindow *win);
|
|||
int wm_window_close_exec(bContext *C, struct wmOperator *op);
|
||||
int wm_window_duplicate_exec(bContext *C, struct wmOperator *op);
|
||||
int wm_window_fullscreen_toggle_exec(bContext *C, struct wmOperator *op);
|
||||
void wm_confirm_quit(bContext *C);
|
||||
void wm_quit_with_optional_confirmation_prompt(bContext *C, wmWindow *win) ATTR_NONNULL();
|
||||
|
||||
/* Initial (unmaximized) size to start with for
|
||||
* systems that can't find it for themselves (X11).
|
||||
|
|
Loading…
Reference in New Issue