diff options
author | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2012-05-29 11:13:25 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-29 15:59:04 +0200 |
commit | d923963118922ca498b90c627c545fb0658d3cdb (patch) | |
tree | 84fd0871ae087ef2c439e637e71dc88b7cefaa82 /tests | |
parent | db6d0371bf6bcc0395c6ee775e85cb4101ba3dab (diff) |
Fixed a crash in QJsonDbWatcher
When the watcher is added and then removed right away, there is an internal
request in the queue that will trigger later and call a _q_onFinished slot in
the watcher, which can hit the assert and crash.
Change-Id: Ibe3cd42b3124328516bce716045597b0319d8364
Reviewed-by: Jamey Hicks <jamey.hicks@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qjsondbwatcher/testqjsondbwatcher.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/auto/qjsondbwatcher/testqjsondbwatcher.cpp b/tests/auto/qjsondbwatcher/testqjsondbwatcher.cpp index 2c1da189..e1cdb477 100644 --- a/tests/auto/qjsondbwatcher/testqjsondbwatcher.cpp +++ b/tests/auto/qjsondbwatcher/testqjsondbwatcher.cpp @@ -92,6 +92,7 @@ private slots: void typeChangeEagerViewSource(); void invalid(); void privatePartition(); + void addAndRemove(); }; TestQJsonDbWatcher::TestQJsonDbWatcher() @@ -806,6 +807,20 @@ void TestQJsonDbWatcher::privatePartition() QVERIFY(!mConnection->addWatcher(&privateWatcher)); } +void TestQJsonDbWatcher::addAndRemove() +{ + QJsonDbWatcher watcher; + watcher.setQuery("[?_type=\"Foo\"]"); + QVERIFY(mConnection->addWatcher(&watcher)); + QVERIFY(mConnection->removeWatcher(&watcher)); + + // a dummy request so that we can safely wait for the (internal) watcher + // requests to be processed. + QJsonDbReadRequest read(QStringLiteral("[?_type=\"Foo\"]")); + QVERIFY(mConnection->send(&read)); + QVERIFY(waitForResponse(&read)); +} + QTEST_MAIN(TestQJsonDbWatcher) #include "testqjsondbwatcher.moc" |