Merge branch 'paint-debug'
Detect invalid use of wxPaintDC/wxPaintEvent better. See https://github.com/wxWidgets/wxWidgets/pull/1732
This commit is contained in:
@@ -2335,39 +2335,17 @@ private:
|
||||
wxEVT_NC_PAINT
|
||||
*/
|
||||
|
||||
#if wxDEBUG_LEVEL && defined(__WXMSW__)
|
||||
#define wxHAS_PAINT_DEBUG
|
||||
|
||||
// see comments in src/msw/dcclient.cpp where g_isPainting is defined
|
||||
extern WXDLLIMPEXP_CORE int g_isPainting;
|
||||
#endif // debug
|
||||
|
||||
class WXDLLIMPEXP_CORE wxPaintEvent : public wxEvent
|
||||
{
|
||||
// This ctor is only intended to be used by wxWidgets itself, so it's
|
||||
// intentionally declared as private when not building the library itself.
|
||||
#ifdef WXBUILDING
|
||||
public:
|
||||
wxPaintEvent(int Id = 0)
|
||||
: wxEvent(Id, wxEVT_PAINT)
|
||||
{
|
||||
#ifdef wxHAS_PAINT_DEBUG
|
||||
// set the internal flag for the duration of redrawing
|
||||
g_isPainting++;
|
||||
#endif // debug
|
||||
}
|
||||
#endif // WXBUILDING
|
||||
explicit wxPaintEvent(wxWindowBase* window = NULL);
|
||||
|
||||
// default copy ctor and dtor are normally fine, we only need them to keep
|
||||
// g_isPainting updated in debug build
|
||||
#ifdef wxHAS_PAINT_DEBUG
|
||||
wxPaintEvent(const wxPaintEvent& event)
|
||||
: wxEvent(event)
|
||||
{
|
||||
g_isPainting++;
|
||||
}
|
||||
|
||||
virtual ~wxPaintEvent()
|
||||
{
|
||||
g_isPainting--;
|
||||
}
|
||||
#endif // debug
|
||||
public:
|
||||
// default copy ctor and dtor are fine
|
||||
|
||||
virtual wxEvent *Clone() const wxOVERRIDE { return new wxPaintEvent(*this); }
|
||||
|
||||
@@ -2377,11 +2355,14 @@ private:
|
||||
|
||||
class WXDLLIMPEXP_CORE wxNcPaintEvent : public wxEvent
|
||||
{
|
||||
// This ctor is only intended to be used by wxWidgets itself, so it's
|
||||
// intentionally declared as private when not building the library itself.
|
||||
#ifdef WXBUILDING
|
||||
public:
|
||||
wxNcPaintEvent(int winid = 0)
|
||||
: wxEvent(winid, wxEVT_NC_PAINT)
|
||||
{ }
|
||||
#endif // WXBUILDING
|
||||
explicit wxNcPaintEvent(wxWindowBase* window = NULL);
|
||||
|
||||
public:
|
||||
virtual wxEvent *Clone() const wxOVERRIDE { return new wxNcPaintEvent(*this); }
|
||||
|
||||
private:
|
||||
|
39
include/wx/msw/private/paint.h
Normal file
39
include/wx/msw/private/paint.h
Normal file
@@ -0,0 +1,39 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/msw/private/paint.h
|
||||
// Purpose: Helpers for handling repainting
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2020-02-10
|
||||
// Copyright: (c) 2020 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_MSW_PRIVATE_PAINT_H_
|
||||
#define _WX_MSW_PRIVATE_PAINT_H_
|
||||
|
||||
#include "wx/stack.h"
|
||||
|
||||
namespace wxMSWImpl
|
||||
{
|
||||
|
||||
// Data used by WM_PAINT handler
|
||||
struct PaintData
|
||||
{
|
||||
explicit PaintData(wxWindowMSW* window_)
|
||||
: window(window_),
|
||||
createdPaintDC(false)
|
||||
{
|
||||
}
|
||||
|
||||
// The window being repainted (never null).
|
||||
wxWindowMSW* const window;
|
||||
|
||||
// True if the user-defined paint handler created wxPaintDC.
|
||||
bool createdPaintDC;
|
||||
};
|
||||
|
||||
// Stack storing data for the possibly nested WM_PAINT handlers.
|
||||
extern wxStack<PaintData> paintStack;
|
||||
|
||||
} // namespace wxMSWImpl
|
||||
|
||||
#endif // _WX_MSW_PRIVATE_PAINT_H_
|
Reference in New Issue
Block a user