summaryrefslogtreecommitdiffstats
path: root/tests/auto/qapplication
diff options
context:
space:
mode:
authorMichael Hasselmann <michael@taschenorakel.de>2010-06-07 15:18:54 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2010-06-07 16:09:43 (GMT)
commit0c0f22ec0e36d7001c8195dcc6e390a37118e33e (patch)
tree5732513e6405bbd807f7083e18040a28d654be97 /tests/auto/qapplication
parentc28da4dd467c2763bed5c6b31471f078ac26cee6 (diff)
downloadQt-0c0f22ec0e36d7001c8195dcc6e390a37118e33e.zip
Qt-0c0f22ec0e36d7001c8195dcc6e390a37118e33e.tar.gz
Qt-0c0f22ec0e36d7001c8195dcc6e390a37118e33e.tar.bz2
Fix QApplication/QWidget to really take ownership of input contexts
* src/gui/kernel/[qapplication|qwidget].cpp, tests/auto/qapplication/tst_[qapplication|qwidget].cpp (setInputContext): The documentation for [QApplication|QWidget]::setInputContext claims that the [QApplication|QWidget] instance would take ownership. This commit fixes the setter to also reparent the input context. Furthermore, the crappy test for this setter was improved. Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com>
Diffstat (limited to 'tests/auto/qapplication')
-rw-r--r--tests/auto/qapplication/tst_qapplication.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/tests/auto/qapplication/tst_qapplication.cpp b/tests/auto/qapplication/tst_qapplication.cpp
index 43fbba1..1a38070 100644
--- a/tests/auto/qapplication/tst_qapplication.cpp
+++ b/tests/auto/qapplication/tst_qapplication.cpp
@@ -189,15 +189,22 @@ void tst_QApplication::getSetCheck()
{
int argc = 0;
QApplication obj1(argc, 0, QApplication::GuiServer);
- // QInputContext * QApplication::inputContext()
- // void QApplication::setInputContext(QInputContext *)
MyInputContext *var1 = new MyInputContext;
+
+ // QApplication takes ownership, so check for reparenting:
obj1.setInputContext(var1);
- QCOMPARE((QInputContext *)var1, obj1.inputContext());
+ QCOMPARE(var1->parent(), static_cast<QObject *>(&obj1));
+
+ // Test for self-assignment:
+ obj1.setInputContext(obj1.inputContext());
+ QVERIFY(obj1.inputContext());
+ QCOMPARE(static_cast<QInputContext *>(var1), obj1.inputContext());
+
+ // Resetting the input context to 0 is not allowed:
QTest::ignoreMessage(QtWarningMsg, "QApplication::setInputContext: called with 0 input context");
- obj1.setInputContext((QInputContext *)0);
- QCOMPARE((QInputContext *)var1, obj1.inputContext());
- // delete var1; // No delete, since QApplication takes ownership
+ obj1.setInputContext(0);
+
+ QCOMPARE(static_cast<QInputContext *>(var1), obj1.inputContext());
}
class CloseEventTestWindow : public QWidget