Fix T59946: multiple quit dialogs possible.
authorSebastian Parborg <zeddb>
Fri, 4 Jan 2019 13:23:49 +0000 (14:23 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Fri, 4 Jan 2019 13:45:16 +0000 (14:45 +0100)
Differential Revision: https://developer.blender.org/D4147

source/blender/editors/include/UI_interface.h
source/blender/editors/interface/interface_region_menu_popup.c
source/blender/windowmanager/intern/wm_window.c

index c525d9c..2e31a1a 100644 (file)
@@ -493,6 +493,8 @@ void UI_popup_block_ex(struct bContext *C, uiBlockCreateFunc func, uiBlockHandle
 
 void UI_popup_block_close(struct bContext *C, struct wmWindow *win, uiBlock *block);
 
+bool UI_popup_block_name_exists(struct bContext *C, const char *name);
+
 /* Blocks
  *
  * Functions for creating, drawing and freeing blocks. A Block is a
index bdac03d..e136614 100644 (file)
@@ -648,4 +648,20 @@ void UI_popup_block_close(bContext *C, wmWindow *win, uiBlock *block)
        }
 }
 
+bool UI_popup_block_name_exists(bContext *C, const char *name)
+{
+       bScreen *sc = CTX_wm_screen(C);
+       uiBlock *block;
+       ARegion *ar;
+
+       for (ar = sc->regionbase.first; ar; ar = ar->next) {
+               for (block = ar->uiblocks.first; block; block = block->next) {
+                       if (STREQ(block->name, name)) {
+                               return true;
+                       }
+               }
+       }
+       return false;
+}
+
 /** \} */
index 8be35c1..281a556 100644 (file)
@@ -444,7 +444,9 @@ 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);
+               if (!UI_popup_block_name_exists(C, "confirm_quit_popup")) {
+                       UI_popup_block_invoke(C, block_create_confirm_quit, NULL);
+               }
        }
        else if (GHOST_confirmQuit(win->ghostwin)) {
                wm_exit_schedule_delayed(C);