No changes, just use wxRecursionGuard instead of manual boolean flag.

Use wxRecursionGuard with the flag indicating whether the mouse capture is
changing to ensure that we always reset it correctly and make the code
slightly shorter.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74674 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2013-08-18 13:28:06 +00:00
parent ae1cdb2d07
commit b0ad1918b9

View File

@@ -72,6 +72,7 @@
#endif
#include "wx/platinfo.h"
#include "wx/recguard.h"
#include "wx/private/window.h"
#ifdef __WINDOWS__
@@ -3216,8 +3217,8 @@ struct WindowNext
// the window that currently has mouse capture
wxWindow *current = NULL;
// indicates if execution is inside CaptureMouse/ReleaseMouse
bool changing = false;
// Flag preventing reentrancy in {Capture,Release}Mouse().
wxRecursionGuardFlag changing;
} // wxMouseCapture
@@ -3225,9 +3226,8 @@ void wxWindowBase::CaptureMouse()
{
wxLogTrace(wxT("mousecapture"), wxT("CaptureMouse(%p)"), static_cast<void*>(this));
wxASSERT_MSG( !wxMouseCapture::changing, wxT("recursive CaptureMouse call?") );
wxMouseCapture::changing = true;
wxRecursionGuard guard(wxMouseCapture::changing);
wxASSERT_MSG( !guard.IsInside(), wxT("recursive CaptureMouse call?") );
wxWindow *winOld = GetCapture();
if ( winOld )
@@ -3244,23 +3244,20 @@ void wxWindowBase::CaptureMouse()
DoCaptureMouse();
wxMouseCapture::current = (wxWindow*)this;
wxMouseCapture::changing = false;
}
void wxWindowBase::ReleaseMouse()
{
wxLogTrace(wxT("mousecapture"), wxT("ReleaseMouse(%p)"), static_cast<void*>(this));
wxASSERT_MSG( !wxMouseCapture::changing, wxT("recursive ReleaseMouse call?") );
wxRecursionGuard guard(wxMouseCapture::changing);
wxASSERT_MSG( !guard.IsInside(), wxT("recursive ReleaseMouse call?") );
wxASSERT_MSG( GetCapture() == this,
"attempt to release mouse, but this window hasn't captured it" );
wxASSERT_MSG( wxMouseCapture::current == this,
"attempt to release mouse, but this window hasn't captured it" );
wxMouseCapture::changing = true;
DoReleaseMouse();
wxMouseCapture::current = NULL;
@@ -3275,8 +3272,6 @@ void wxWindowBase::ReleaseMouse()
}
//else: stack is empty, no previous capture
wxMouseCapture::changing = false;
wxLogTrace(wxT("mousecapture"),
(const wxChar *) wxT("After ReleaseMouse() mouse is captured by %p"),
static_cast<void*>(GetCapture()));
@@ -3301,7 +3296,8 @@ void wxWindowBase::NotifyCaptureLost()
{
// don't do anything if capture lost was expected, i.e. resulted from
// a wx call to ReleaseMouse or CaptureMouse:
if ( wxMouseCapture::changing )
wxRecursionGuard guard(wxMouseCapture::changing);
if ( guard.IsInside() )
return;
// if the capture was lost unexpectedly, notify every window that has