]> git.saurik.com Git - wxWidgets.git/commitdiff
tracking open modal dialogs
authorStefan Csomor <csomor@advancedconcepts.ch>
Tue, 20 Apr 2010 19:09:38 +0000 (19:09 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Tue, 20 Apr 2010 19:09:38 +0000 (19:09 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64068 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/osx/dialog.h
src/osx/carbon/colordlg.cpp
src/osx/carbon/colordlgosx.mm
src/osx/carbon/dirdlg.cpp
src/osx/carbon/filedlg.cpp
src/osx/carbon/fontdlg.cpp
src/osx/carbon/fontdlgosx.mm
src/osx/carbon/msgdlg.cpp
src/osx/carbon/printdlg.cpp
src/osx/dialog_osx.cpp

index 83dd07b8165000015f0314bab0b0ced6d3fb912f..9442b943739918c235c2bc5f674bb61e21c4f213 100644 (file)
@@ -61,6 +61,10 @@ public:
 
     // may be called to terminate the dialog with the given return code
     virtual void EndModal(int retCode);
+    
+    static bool OSXHasModalDialogsOpen();
+    static void OSXBeginModalDialog();
+    static void OSXEndModalDialog();
 
     // implementation
     // --------------
index 6ec1b9e15a9fb637b3d7689599bf12be9ec293d8..c62b2ae5e4d86d1f5144b0415c2f5f790658d6cc 100644 (file)
@@ -59,7 +59,9 @@ int wxColourDialog::ShowModal()
     info.theColor.color.rgb.red =  currentColor.red ;
     info.theColor.color.rgb.green =  currentColor.green ;
     info.theColor.color.rgb.blue =  currentColor.blue ;
+    wxDialog::OSXBeginModalDialog();
     err = NPickColor(&info);
+    wxDialog::OSXEndModalDialog();
     if ((err == noErr) && info.newColorChosen)
     {
         currentColor.red = info.theColor.color.rgb.red ;
index 067e5b413ce1eebdefab5e0f3dec4524c9f2a7c1..0f75e74eef432163079cf0bdddd1494f9f7b8865 100644 (file)
@@ -141,6 +141,7 @@ int wxColourDialog::ShowModal()
             //
             // Start the color panel modal loop
             //
+            wxDialog::OSXBeginModalDialog();
             NSModalSession session = [NSApp beginModalSessionForWindow:theColorPanel];
             for (;;)
             {
@@ -151,6 +152,7 @@ int wxColourDialog::ShowModal()
                     break;
             }
             [NSApp endModalSession:session];
+            wxDialog::OSXEndModalDialog();
 
     //free up the memory for the delegates - we don't need them anymore
     [theColorPanel setDelegate:nil];
index c653e17e20ddd83e25a9fe867dc26c6b2e1eecd0..c8a97726f1a54ca3902d418c13ac0f14196f5c02 100644 (file)
@@ -88,7 +88,9 @@ int wxDirDialog::ShowModal()
         err = NavCreateChooseFolderDialog(&options, sStandardNavEventFilter , NULL,  this , &dialog);
         if (err == noErr)
         {
+            wxDialog::OSXBeginModalDialog();
             err = NavDialogRun(dialog);
+            wxDialog::OSXEndModalDialog();
             if ( err == noErr )
             {
                 err = NavDialogGetReply(dialog, &reply);
index 4fb787eacff74d2558040e61bb80a058e7fde5d1..158846b529923de8e3c7190e5e7935401ae6fdaf 100644 (file)
@@ -541,7 +541,11 @@ int wxFileDialog::ShowModal()
     SetupExtraControls(NavDialogGetWindow(dialog));
     
     if (err == noErr)
+    {
+        wxDialog::OSXBeginModalDialog();
         err = ::NavDialogRun(dialog);
+        wxDialog::OSXEndModalDialog();
+    }
 
     // clean up filter related data, etc.
     if (navFilterUPP)
index 1e83fe0ee293a489c3c284ec45902201604795f2..cf0aed1759e08100ca75166b9ec21285dd1d6e86 100644 (file)
@@ -257,8 +257,9 @@ int wxFontDialog::ShowModal()
     if ( !FPIsFontPanelVisible() )
         FPShowHideFontPanel();
 #endif
+    wxDialog::OSXBeginModalDialog();
     int retval = RunMixedFontDialog(this);
-
+    wxDialog::OSXEndModalDialog();
 #if wxOSX_USE_CARBON
     ::RemoveEventHandler(handler);
 #endif
index bb8f35642a10e0fa5c7d1281ccf70379a25b8205..a83b7d5e028970d428676dd9631ad7e75ae71e05 100644 (file)
@@ -453,6 +453,7 @@ int wxFontDialog::ShowModal()
     //  the color panel until the color panel closes, switching
     //  back to the font panel modal loop once it does close.
     //
+    wxDialog::OSXBeginModalDialog();
     do
     {
         //
@@ -491,7 +492,8 @@ int wxFontDialog::ShowModal()
         //out of its modal loop because the color panel was
         //opened) return the font panel modal loop
     }while([theFPDelegate isClosed] == NO);
-
+    wxDialog::OSXEndModalDialog();
+    
     //free up the memory for the delegates - we don't need them anymore
     [theFPDelegate release];
     [theCPDelegate release];
index a95138112e9576401575abbfd46ae5043354d6f4..bc410c3c037e185b3fa3b4e9184463ad3c165d93 100644 (file)
@@ -216,7 +216,9 @@ int wxMessageDialog::ShowModal()
         {
             DialogRef alertRef;
             CreateStandardAlert( alertType, cfTitle, cfText, &param, &alertRef );
+            wxDialog::OSXBeginModalDialog();
             RunStandardAlert( alertRef, NULL, &result );
+            wxDialog::OSXEndModalDialog();
         }
         else
         {
index fae5551255bd1f796db386566c7941177e71a22a..3f36361060f38cf6f1bac980e6511d950bc1ad0d 100644 (file)
@@ -39,8 +39,10 @@ int wxMacPrintDialog::ShowModal()
     OSErr err = noErr;
     Boolean accepted;
     wxOSXPrintData* nativeData = (wxOSXPrintData*)m_printDialogData.GetPrintData().GetNativeData();
+    wxDialog::OSXBeginModalDialog();
     err = PMSessionPrintDialog(nativeData->GetPrintSession(), nativeData->GetPrintSettings(),
         nativeData->GetPageFormat(), &accepted );
+    wxDialog::OSXEndModalDialog();
 
     if ((err == noErr) && !accepted)
     {
@@ -80,8 +82,10 @@ int wxMacPageSetupDialog::ShowModal()
     OSErr err = noErr;
     Boolean accepted;
 
+    wxDialog::OSXBeginModalDialog();
     err = PMSessionPageSetupDialog( nativeData->GetPrintSession(), nativeData->GetPageFormat(),
         &accepted );
+    wxDialog::OSXEndModalDialog();
 
     if ((err == noErr) && !accepted)
     {
index e605e95f3fa511ead9e4b5e98bfefe4a4191b3af..b1b50b980a5bb5c2b3effcbb42d484bf160b6f32 100644 (file)
 
 #include "wx/osx/private.h"
 
-// Lists to keep track of windows, so we can disable/enable them
-// for modal dialogs
+static int s_openDialogs = 0;
+bool wxDialog::OSXHasModalDialogsOpen()
+{
+    return s_openDialogs > 0;
+}
+
+void wxDialog::OSXBeginModalDialog()
+{
+    s_openDialogs++;
+}
+
+void wxDialog::OSXEndModalDialog()
+{
+    wxASSERT_MSG( s_openDialogs > 0, "incorrect internal modal dialog count");
+    s_openDialogs--;
+}
 
-wxList wxModalDialogs;
 
 IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxTopLevelWindow)
 
@@ -130,7 +143,9 @@ int wxDialog::ShowModal()
     wxModalEventLoop modalLoop(this);
     m_eventLoop = &modalLoop;
     
+    wxDialog::OSXBeginModalDialog();
     modalLoop.Run();
+    wxDialog::OSXEndModalDialog();
     
     m_eventLoop = NULL;