Fix memory leaks in tst_qlineedit
In the unit tests, two times a validator was used without a parent, which led to memory leaks. This patch changes this: The validators are initialized with the widget they are meant for as parent. This fixes the memory leaks. Pick-to: 6.2 Change-Id: I480c0c5104cbe60159fad49df28cbb6240e7ce68 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
This commit is contained in:
parent
eaa48136a3
commit
b854bf06dc
@ -3322,7 +3322,7 @@ void tst_QLineEdit::validateOnFocusOut()
|
||||
|
||||
QLineEdit *testWidget = ensureTestWidget();
|
||||
QSignalSpy editingFinishedSpy(testWidget, SIGNAL(editingFinished()));
|
||||
testWidget->setValidator(new QIntValidator(100, 999, 0));
|
||||
testWidget->setValidator(new QIntValidator(100, 999, testWidget));
|
||||
QTest::keyPress(testWidget, '1');
|
||||
QTest::keyPress(testWidget, '0');
|
||||
QCOMPARE(testWidget->text(), QString("10"));
|
||||
@ -3347,7 +3347,7 @@ void tst_QLineEdit::editInvalidText()
|
||||
{
|
||||
QLineEdit *testWidget = ensureTestWidget();
|
||||
testWidget->clear();
|
||||
testWidget->setValidator(new QIntValidator(0, 12, 0));
|
||||
testWidget->setValidator(new QIntValidator(0, 12, testWidget));
|
||||
testWidget->setText("1234");
|
||||
|
||||
QVERIFY(!testWidget->hasAcceptableInput());
|
||||
|
Loading…
x
Reference in New Issue
Block a user