From 72a24b402b0075629ad3c19abb1d17665b25e5e1 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 22 Feb 2021 14:26:23 +0100 Subject: [PATCH] Fix deleting of wxTextCtrl in wxNumValidator test case This was broken in da973c3caf (Get rid of CppUnit boilerplate in numeric validator unit tests, 2021-02-21) which replaced DestroyChildren() in the old CppUnit test case dtor with just "delete m_text", as this didn't take care of "text2" created in one of the tests. Using DestroyChildren() still seems overly side, so ensure that "text2" is destroyed explicitly. --- tests/validators/valnum.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/validators/valnum.cpp b/tests/validators/valnum.cpp index b4fb2ae277..b91129359c 100644 --- a/tests/validators/valnum.cpp +++ b/tests/validators/valnum.cpp @@ -20,6 +20,8 @@ #include "asserthelper.h" #include "testableframe.h" + +#include "wx/scopeguard.h" #include "wx/uiaction.h" class NumValidatorTestCase @@ -243,6 +245,7 @@ TEST_CASE_METHOD(NumValidatorTestCase, "ValNum::Interactive", "[valnum]") // Create a sibling text control to be able to switch focus and thus // trigger the control validation/normalization. wxTextCtrl * const text2 = new wxTextCtrl(m_text->GetParent(), wxID_ANY); + wxON_BLOCK_EXIT_OBJ0( *text2, wxWindow::Destroy ); text2->Move(10, 80); // Just to see it better while debugging... wxFloatingPointValidator valFloat(3); valFloat.SetRange(-10., 10.);