]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix closing logic in wxMSW native wxProgressDialog.
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 10 Sep 2010 17:26:07 +0000 (17:26 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 10 Sep 2010 17:26:07 +0000 (17:26 +0000)
The dialog must always close if the C++ object was destroyed, independently of
whether it was cancelled or finished.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65508 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/progdlg.cpp

index 59cf1038246057be6aeabd412bf08126d074e66e..affd761eda2b9c02ffcebe158949e31039ccc05e 100644 (file)
@@ -892,22 +892,19 @@ wxProgressDialogTaskRunner::TaskDialogCallbackProc
         case TDN_TIMER:
             PerformNotificationUpdates(hwnd, sharedData);
 
-            // End dialog in three different cases:
-            // 1. Progress finished and dialog should automatically hide.
-            // 2. The wxProgressDialog object was destructed and should
-            //    automatically hide.
-            // 3. The dialog was canceled and wxProgressDialog object
-            //    was destroyed.
-            bool isCanceled =
-                sharedData->m_state == wxGenericProgressDialog::Canceled;
-            bool isFinished =
-                sharedData->m_state == wxGenericProgressDialog::Finished;
-            bool wasDestroyed =
-                (sharedData->m_notifications & wxSPDD_DESTROYED) != 0;
-            bool shouldAutoHide = (sharedData->m_style & wxPD_AUTO_HIDE) != 0;
-
-            if ( (shouldAutoHide && (isFinished || wasDestroyed))
-                 || (wasDestroyed && isCanceled) )
+            /*
+                Decide whether we should end the dialog. This is done if either
+                the dialog object itself was destroyed or if the progress
+                finished and we were configured to hide automatically without
+                waiting for the user to dismiss us.
+
+                Notice that we do not close the dialog if it was cancelled
+                because it's up to the user code in the main thread to decide
+                whether it really wants to cancel the dialog.
+             */
+            if ( (sharedData->m_notifications & wxSPDD_DESTROYED) ||
+                    (sharedData->m_state == wxProgressDialog::Finished &&
+                        sharedData->m_style & wxPD_AUTO_HIDE) )
             {
                 ::EndDialog( hwnd, IDCLOSE );
             }