Use wxWindow::Refresh() instead of artificial wxPaintEvent in the test.
This fixes memory leaks under wxMSW: as the test code didn't (and couldn't) call wxPaintDCImpl::EndPaint(), there was a leak for each wxPaintEvent generated in it since the changes to wxDC caching in r72938. It's also preferable because it uses public API instead of feeding events to the window which is not documented to work. Unfortunately even using Refresh() still doesn't allow the test to work under wxOSX. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73929 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
a7c0de8a98
commit
233666915e
@ -30,6 +30,16 @@
|
||||
#include "wx/scopedptr.h"
|
||||
#include "wx/scopeguard.h"
|
||||
|
||||
// FIXME: Currently under OS X testing paint event doesn't work because neither
|
||||
// calling Refresh()+Update() nor even sending wxPaintEvent directly to
|
||||
// the window doesn't result in calls to its event handlers, so disable
|
||||
// some tests there. But this should be fixed and the tests reenabled
|
||||
// because wxPaintEvent propagation in wxScrolledWindow is a perfect
|
||||
// example of fragile code that could be broken under OS X.
|
||||
#ifndef __WXOSX__
|
||||
#define CAN_TEST_PAINT_EVENTS
|
||||
#endif
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
@ -159,6 +169,21 @@ public:
|
||||
Connect(wxEVT_PAINT, wxPaintEventHandler(TestScrollWindow::OnPaint));
|
||||
}
|
||||
|
||||
void GeneratePaintEvent()
|
||||
{
|
||||
#ifdef __WXGTK__
|
||||
// We need to map the window, otherwise we're not going to get any
|
||||
// paint events for it.
|
||||
wxYield();
|
||||
|
||||
// Ignore events generated during the initial mapping.
|
||||
g_str.clear();
|
||||
#endif // __WXGTK__
|
||||
|
||||
Refresh();
|
||||
Update();
|
||||
}
|
||||
|
||||
virtual void OnDraw(wxDC& WXUNUSED(dc))
|
||||
{
|
||||
g_str += 'D'; // draw
|
||||
@ -351,11 +376,11 @@ void EventPropagationTestCase::ScrollWindowWithoutHandler()
|
||||
|
||||
TestScrollWindow * const win = new TestScrollWindow(parent);
|
||||
|
||||
#if !defined(__WXOSX__) && !defined(__WXGTK3__)
|
||||
wxPaintEvent event(win->GetId());
|
||||
win->ProcessWindowEvent(event);
|
||||
#ifdef CAN_TEST_PAINT_EVENTS
|
||||
win->GeneratePaintEvent();
|
||||
CPPUNIT_ASSERT_EQUAL( "PD", g_str );
|
||||
#endif
|
||||
|
||||
g_str.clear();
|
||||
wxCommandEvent eventCmd(TEST_EVT);
|
||||
win->HandleWindowEvent(eventCmd);
|
||||
@ -369,13 +394,12 @@ void EventPropagationTestCase::ScrollWindowWithHandler()
|
||||
|
||||
TestScrollWindow * const win = new TestScrollWindow(parent);
|
||||
|
||||
#if !defined(__WXOSX__) && !defined(__WXGTK3__)
|
||||
#ifdef CAN_TEST_PAINT_EVENTS
|
||||
TestPaintEvtHandler h('h');
|
||||
win->PushEventHandler(&h);
|
||||
wxON_BLOCK_EXIT_OBJ1( *win, wxWindow::PopEventHandler, false );
|
||||
|
||||
wxPaintEvent event(win->GetId());
|
||||
win->ProcessWindowEvent(event);
|
||||
win->GeneratePaintEvent();
|
||||
CPPUNIT_ASSERT_EQUAL( "ohPD", g_str );
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user