Make sure that TextInteractionFlags get set.
authorFrederik Gladhorn <frederik.gladhorn@digia.com>
Tue, 19 Mar 2013 14:04:44 +0000 (15:04 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Tue, 19 Mar 2013 19:19:09 +0000 (20:19 +0100)
The first time the function is called,
it could fail to set the flags.

Calling setSelectByKeyboard(true) would not actually
set the text interaction flags (was == on).

The test didn't detect it because it called setReadOnly
before setSelectByKeyboard.

Change-Id: Ia54cc782b6ad5a74f1d7029c92fa230116d034b0
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
src/quick/items/qquicktextedit.cpp
tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp

index e30b9cb..feabbba 100644 (file)
@@ -1265,8 +1265,8 @@ void QQuickTextEdit::setSelectByKeyboard(bool on)
 {
     Q_D(QQuickTextEdit);
     bool was = selectByKeyboard();
-    d->selectByKeyboardSet = true;
-    if (was != on) {
+    if (!d->selectByKeyboardSet || was != on) {
+        d->selectByKeyboardSet = true;
         d->selectByKeyboard = on;
         if (on)
             d->control->setTextInteractionFlags(d->control->textInteractionFlags() | Qt::TextSelectableByKeyboard);
index b9041fb..bce1f9e 100644 (file)
@@ -2171,8 +2171,8 @@ void tst_qquicktextedit::keyboardSelection()
     QVERIFY(edit);
 
     edit->setText(text);
-    edit->setReadOnly(readOnly);
     edit->setSelectByKeyboard(selectByKeyboard);
+    edit->setReadOnly(readOnly);
     edit->setCursorPosition(cursorPosition);
 
     QQuickWindow window;