Simplify WaitForPaint::YieldUntilPainted()

Don't return anything from it, just warn directly -- this is what all
the existing callers did, so it's simpler if the function just does it
itself instead of forcing them to check its return value.

Also reset m_painted after yielding, so that YieldUntilPainted() could
be called again, if necessary.
This commit is contained in:
Vadim Zeitlin
2021-01-31 00:29:31 +01:00
parent e0a927af94
commit 4da635e2dc
3 changed files with 14 additions and 14 deletions

View File

@@ -122,10 +122,7 @@ GridTestCase::GridTestCase()
m_grid->Refresh(); m_grid->Refresh();
m_grid->Update(); m_grid->Update();
if ( !waitForPaint.YieldUntilPainted() ) waitForPaint.YieldUntilPainted();
{
WARN("Grid not repainted until timeout expiration");
}
} }
GridTestCase::~GridTestCase() GridTestCase::~GridTestCase()

View File

@@ -29,8 +29,8 @@ public:
} }
// This function waits up to the given number of milliseconds for the paint // This function waits up to the given number of milliseconds for the paint
// event to come and returns true if we did get it or false otherwise. // event to come and logs a warning if we didn't get it.
bool YieldUntilPainted(int timeoutInMS = 250) const void YieldUntilPainted(int timeoutInMS = 250)
{ {
wxStopWatch sw; wxStopWatch sw;
for ( ;; ) for ( ;; )
@@ -38,10 +38,17 @@ public:
wxYield(); wxYield();
if ( m_painted ) if ( m_painted )
return true; {
// Reset it in case YieldUntilPainted() is called again.
m_painted = false;
break;
}
if ( sw.Time() > timeoutInMS ) if ( sw.Time() > timeoutInMS )
return false; {
WARN("Didn't get a paint event until timeout expiration");
break;
}
} }
} }
@@ -85,9 +92,8 @@ public:
{ {
} }
bool YieldUntilPainted(int WXUNUSED(timeoutInMS) = 250) const void YieldUntilPainted(int WXUNUSED(timeoutInMS) = 250)
{ {
return true;
} }
}; };

View File

@@ -98,10 +98,7 @@ TEST_CASE("wxWindow::MovePreservesSize", "[window][size][move]")
w->Show(); w->Show();
if ( !waitForPaint.YieldUntilPainted() ) waitForPaint.YieldUntilPainted();
{
WARN("Didn't get a paint event until timeout expiration");
}
const wxRect rectOrig = w->GetRect(); const wxRect rectOrig = w->GetRect();