summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSamuel Gaist <samuel.gaist@idiap.ch>2018-11-25 21:58:47 +0100
committerSamuel Gaist <samuel.gaist@idiap.ch>2019-02-12 15:29:49 +0000
commitdd1a6308719929b0798447244b401376d983cfbf (patch)
tree65fc14cf1b1c5be0a973bbde6e3d842e0a2387af /tests
parentdf2b76046de4af7a47fa8303d5f261e3c5d120fe (diff)
QLineEdit: don't emit editingFinished if nothing was done
When a modal dialog is called from a slot connected to the editingFinished signal, the chain of events resulting from the focus returning to this widget will make the editingFinished signal emitted again. This patch uses a new variable to keep track of the fact that there was a modification. Once editingFinished was emitted, that flag is cleared so next time the signal will be emitted again only if a modification was made to the line edit content. [ChangeLog][QtWidget][QLineEdit] Behavior change: now the editingFinished signal is emitted only once after the line edit content was edited. Fixes: QTBUG-40 Change-Id: Ia4760bad8717f1758c3939132c446b4b4c6cd498 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
index 95799905de..7861065de9 100644
--- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
@@ -3615,6 +3615,14 @@ void tst_QLineEdit::task174640_editingFinished()
le2->setFocus();
QTRY_VERIFY(le2->hasFocus());
+ // editingFinished will not be emitted anew because no editing happened
+ QCOMPARE(editingFinishedSpy.count(), 0);
+
+ le1->setFocus();
+ QTRY_VERIFY(le1->hasFocus());
+ QTest::keyPress(le1, Qt::Key_Plus);
+ le2->setFocus();
+ QTRY_VERIFY(le2->hasFocus());
QCOMPARE(editingFinishedSpy.count(), 1);
editingFinishedSpy.clear();
@@ -3632,6 +3640,8 @@ void tst_QLineEdit::task174640_editingFinished()
delete testMenu1;
QCOMPARE(editingFinishedSpy.count(), 0);
QTRY_VERIFY(le1->hasFocus());
+ // Ensure le1 has been edited
+ QTest::keyPress(le1, Qt::Key_Plus);
QMenu *testMenu2 = new QMenu(le2);
testMenu2->addAction("foo2");