Remove wxHAS_PAINT_DEBUG and code guarded by it

This doesn't seem to actually be doing anything useful, as it only
checks that wxPaintDCImpl is not created without creating wxPaintDC
which is impossible to do accidentally anyhow.

This will be replaced by a more useful check in the next commit.
This commit is contained in:
Vadim Zeitlin
2020-02-10 13:14:08 +01:00
parent 5fb7f89b14
commit f6158bc343
2 changed files with 1 additions and 46 deletions

View File

@@ -2335,39 +2335,15 @@ private:
wxEVT_NC_PAINT 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 class WXDLLIMPEXP_CORE wxPaintEvent : public wxEvent
{ {
public: public:
wxPaintEvent(int Id = 0) wxPaintEvent(int Id = 0)
: wxEvent(Id, wxEVT_PAINT) : wxEvent(Id, wxEVT_PAINT)
{ {
#ifdef wxHAS_PAINT_DEBUG
// set the internal flag for the duration of redrawing
g_isPainting++;
#endif // debug
} }
// default copy ctor and dtor are normally fine, we only need them to keep // default copy ctor and dtor are fine
// g_isPainting updated in debug build
#ifdef wxHAS_PAINT_DEBUG
wxPaintEvent(const wxPaintEvent& event)
: wxEvent(event)
{
g_isPainting++;
}
virtual ~wxPaintEvent()
{
g_isPainting--;
}
#endif // debug
virtual wxEvent *Clone() const wxOVERRIDE { return new wxPaintEvent(*this); } virtual wxEvent *Clone() const wxOVERRIDE { return new wxPaintEvent(*this); }

View File

@@ -138,18 +138,6 @@ PaintDCInfos gs_PaintDCInfos;
} // anonymous namespace } // anonymous namespace
// ----------------------------------------------------------------------------
// global variables
// ----------------------------------------------------------------------------
#ifdef wxHAS_PAINT_DEBUG
// a global variable which we check to verify that wxPaintDC are only
// created in response to WM_PAINT message - doing this from elsewhere is a
// common programming error among wxWidgets programmers and might lead to
// very subtle and difficult to debug refresh/repaint bugs.
int g_isPainting = 0;
#endif // wxHAS_PAINT_DEBUG
// =========================================================================== // ===========================================================================
// implementation // implementation
// =========================================================================== // ===========================================================================
@@ -269,15 +257,6 @@ wxPaintDCImpl::wxPaintDCImpl( wxDC *owner, wxWindow *window ) :
{ {
wxCHECK_RET( window, wxT("NULL canvas in wxPaintDCImpl ctor") ); wxCHECK_RET( window, wxT("NULL canvas in wxPaintDCImpl ctor") );
#ifdef wxHAS_PAINT_DEBUG
if ( g_isPainting <= 0 )
{
wxFAIL_MSG( wxT("wxPaintDCImpl may be created only in EVT_PAINT handler!") );
return;
}
#endif // wxHAS_PAINT_DEBUG
// see comments in src/msw/window.cpp where this is defined // see comments in src/msw/window.cpp where this is defined
extern wxStack<bool> wxDidCreatePaintDC; extern wxStack<bool> wxDidCreatePaintDC;