Don't require calling DoNativeBeforeUpdate() with locked CS

Acquire the lock in wxProgressDialog::DoNativeBeforeUpdate() itself
instead of relying on the caller to do it.

This is just a refactoring in preparation for further changes.
This commit is contained in:
Vadim Zeitlin 2017-10-28 19:31:30 +02:00
parent aac673391c
commit 046d3be215
2 changed files with 20 additions and 13 deletions

View File

@ -54,8 +54,9 @@ public:
virtual WXWidget GetHandle() const wxOVERRIDE;
private:
// Performs common routines to Update() and Pulse(). Requires the
// shared object to have been entered.
// Common part of Update() and Pulse().
//
// Returns false if the user requested cancelling the dialog.
bool DoNativeBeforeUpdate(bool *skip);
// Updates the various timing informations for both determinate

View File

@ -404,17 +404,19 @@ bool wxProgressDialog::Update(int value, const wxString& newmsg, bool *skip)
#ifdef wxHAS_MSW_TASKDIALOG
if ( HasNativeTaskDialog() )
{
if ( !DoNativeBeforeUpdate(skip) )
{
// Dialog was cancelled.
return false;
}
value /= m_factor;
wxASSERT_MSG( value <= m_maximum, wxT("invalid progress value") );
{
wxCriticalSectionLocker locker(m_sharedData->m_cs);
// Do nothing in canceled state.
if ( !DoNativeBeforeUpdate(skip) )
return false;
value /= m_factor;
wxASSERT_MSG( value <= m_maximum, wxT("invalid progress value") );
m_sharedData->m_value = value;
m_sharedData->m_notifications |= wxSPDD_VALUE_CHANGED;
@ -474,11 +476,13 @@ bool wxProgressDialog::Pulse(const wxString& newmsg, bool *skip)
#ifdef wxHAS_MSW_TASKDIALOG
if ( HasNativeTaskDialog() )
{
wxCriticalSectionLocker locker(m_sharedData->m_cs);
// Do nothing in canceled state.
if ( !DoNativeBeforeUpdate(skip) )
{
// Dialog was cancelled.
return false;
}
wxCriticalSectionLocker locker(m_sharedData->m_cs);
if ( !m_sharedData->m_progressBarMarquee )
{
@ -509,6 +513,8 @@ bool wxProgressDialog::DoNativeBeforeUpdate(bool *skip)
#ifdef wxHAS_MSW_TASKDIALOG
if ( HasNativeTaskDialog() )
{
wxCriticalSectionLocker locker(m_sharedData->m_cs);
if ( m_sharedData->m_skipped )
{
if ( skip && !*skip )