Use non-static reentrancy guard in wxScrollHelper::AdjustScrollbars().

This prevented calls to AdjustScrollbars() of another window from doing
anything if they were called due to a size change from AdjustScrollbars() of
an outer window.

Closes #16852.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@78491 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2015-02-14 19:09:39 +00:00
parent e22fcf204e
commit 1cfd935c26
2 changed files with 55 additions and 4 deletions

View File

@@ -583,6 +583,7 @@ All (GUI):
- Restore support for wxFD_OVERWRITE_PROMPT and wxFD_FILE_MUST_EXIST in
wxGenericFileDialog which was accidentally lost some time ago (Carl Godkin).
- Fix handling of fast consecutive clicks in wxRibbonBar (atobi).
- Fix updating nested window scrollbars in some cases (sbrowne).
wxGTK:

View File

@@ -39,8 +39,6 @@
#include "wx/scrolbar.h"
#endif
#include "wx/recguard.h"
#ifdef __WXMSW__
#include <windows.h> // for DLGC_WANTARROWS
#include "wx/msw/winundef.h"
@@ -58,6 +56,58 @@
#endif
#endif
typedef wxVector<wxScrollHelper *> wxScrollHelperRecGuardFlags;
class wxScrollHelperRecGuard
{
public:
wxScrollHelperRecGuard(wxScrollHelper *instance, wxScrollHelperRecGuardFlags& flags)
: m_flags(flags), m_instance(instance), m_inside(false)
{
// Determine if our instance is already inside a guard
for ( wxScrollHelperRecGuardFlags::iterator iter = flags.begin();
iter != flags.end();
++iter )
{
if ( *iter == instance )
{
m_inside = true;
return;
}
}
// Not inside so add it to the back
flags.push_back(instance);
}
~wxScrollHelperRecGuard()
{
if ( IsInside() )
return;
for ( wxScrollHelperRecGuardFlags::iterator iter = m_flags.begin();
iter != m_flags.end();
++iter )
{
if ( *iter == m_instance )
{
m_flags.erase(iter);
break;
}
}
}
bool IsInside() const { return m_inside; }
private:
wxScrollHelperRecGuardFlags& m_flags;
wxScrollHelper* m_instance;
// true if the flag had been already set when we were created
bool m_inside;
wxDECLARE_NO_COPY_CLASS(wxScrollHelperRecGuard);
};
/*
TODO PROPERTIES
style wxHSCROLL | wxVSCROLL
@@ -1303,8 +1353,8 @@ wxScrollHelper::DoAdjustScrollbar(int orient,
void wxScrollHelper::AdjustScrollbars()
{
static wxRecursionGuardFlag s_flagReentrancy;
wxRecursionGuard guard(s_flagReentrancy);
static wxScrollHelperRecGuardFlags s_flagReentrancy;
wxScrollHelperRecGuard guard(this, s_flagReentrancy);
if ( guard.IsInside() )
{
// don't reenter AdjustScrollbars() while another call to