Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <eiseljulian@gmail.com>2018-03-23 04:00:14 +0300
committerJulian Eisel <eiseljulian@gmail.com>2018-03-23 04:00:14 +0300
commit529c21acc2e6e0830844a610d4f8d6a9b72a9902 (patch)
tree14a4888aae58eb1bf6b2caa759cbee6970db7f39
parentaeec19d2e76fc292d21d00090d02c672c3997647 (diff)
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.
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c10
-rw-r--r--source/blender/windowmanager/intern/wm_window.c62
-rw-r--r--source/blender/windowmanager/wm_window.h2
3 files changed, 39 insertions, 35 deletions
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index bf2f00e9460..1c21069879a 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -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;
}
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 6573ae0f4a1..408229e501c 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -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 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);
- /* 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);
+ 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 */
diff --git a/source/blender/windowmanager/wm_window.h b/source/blender/windowmanager/wm_window.h
index 4313c978ef4..5209af87960 100644
--- a/source/blender/windowmanager/wm_window.h
+++ b/source/blender/windowmanager/wm_window.h
@@ -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).