Avoid asserts when destroying windows with mouse capture in tests

Destroying a window with mouse capture results in an assert, which is
translated into an exception when running the test suite. As this exception is
thrown from wxWindowBase dtor, it results in an immediate program termination
when using C++11 and can also have the same effect even when using C++98 if
this exception is thrown while already handling another exception due to a
test failure.

Try to avoid this by using a "safe" DeleteTestWindow() function instead of
deleting the window directly. Currently this function ensures that the window
doesn't have mouse capture before deleting it, but it could also be used to
check for other things later. Also, this commit only uses this function for
the two controls which do happen to be destroyed with mouse capture currently
(at least when using wxGTK), but it should probably be generalized to all
controls in the future.
This commit is contained in:
Vadim Zeitlin
2016-06-29 18:22:05 +02:00
parent dae164b8aa
commit 8686ca62e7
4 changed files with 30 additions and 2 deletions

View File

@@ -78,7 +78,8 @@ void HtmlWindowTestCase::setUp()
void HtmlWindowTestCase::tearDown()
{
wxDELETE(m_win);
DeleteTestWindow(m_win);
m_win = NULL;
}
// ----------------------------------------------------------------------------