From: Vadim Zeitlin Date: Fri, 10 Sep 2010 17:26:07 +0000 (+0000) Subject: Fix closing logic in wxMSW native wxProgressDialog. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/21a5e7e0a73ebcf8bd588e1c6cb4aea518dae572 Fix closing logic in wxMSW native wxProgressDialog. 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 --- diff --git a/src/msw/progdlg.cpp b/src/msw/progdlg.cpp index 59cf103824..affd761eda 100644 --- a/src/msw/progdlg.cpp +++ b/src/msw/progdlg.cpp @@ -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 ); }