summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTapani Mikola <tapani.mikola@nokia.com>2012-06-11 14:39:11 +0300
committerQt by Nokia <qt-info@nokia.com>2012-06-11 15:24:35 +0200
commit9ff47024513a024ecfc34540e1670d8d80c0f48d (patch)
tree82e25f69347a234c78265fa87192e8f1efa28031 /src
parentb80efec0b680d925efc30174b6721c0db0d8c741 (diff)
Fix a crash in query model
Query model (and list model that uses it) was crashing, if query was changed while the model had pending queries. Change-Id: Ibaa5c72696d201200ba4e5c53d17594625df3b97 Reviewed-by: Jamey Hicks <jamey.hicks@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/client/qjsondbquerymodel_p.cpp32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/client/qjsondbquerymodel_p.cpp b/src/client/qjsondbquerymodel_p.cpp
index bec3667..1df87ed 100644
--- a/src/client/qjsondbquerymodel_p.cpp
+++ b/src/client/qjsondbquerymodel_p.cpp
@@ -445,7 +445,6 @@ void QJsonDbQueryModelPrivate::emitDataChanged(int from, int to)
void QJsonDbQueryModelPrivate::generateCustomData(QJsonObject &val)
{
- Q_Q(QJsonDbQueryModel);
QJSValueList args;
args << injectCallback.engine()->toScriptValue(val);
QJSValue retVal = injectCallback.call(args);
@@ -573,9 +572,19 @@ void QJsonDbQueryModelPrivate::reset()
for (int i = 0; i < partitionObjectUuids.count(); i++) {
partitionObjectUuids[i].clear();
}
+ for (int i = 0; i < indexRequests.count(); i++) {
+ indexRequests[i]->resetRequest();
+ }
+ for (int i = 0; i < keyRequests.count(); i++) {
+ keyRequests[i]->resetRequest();
+ }
+ for (int i = 0; i < valueRequests.count(); i++) {
+ valueRequests[i]->resetRequest();
+ }
objectCache.clear();
objectUuids.clear();
+ tmpObjects.clear();
objectSortValues.clear();
currentCacheRequest.clear();
cacheMiss.clear();
@@ -652,12 +661,30 @@ void QJsonDbQueryModelPrivate::initializeModel(bool reset)
objectCache.clear();
objectUuids.clear();
objectSortValues.clear();
+ tmpObjects.clear();
+ currentCacheRequest.clear();
+ cacheMiss.clear();
+ requestQueue.clear();
+
for (int i = 0; i < partitionObjectUuids.count(); i++) {
partitionObjectUuids[i].clear();
}
for (int i = 0; i < partitionIndexDetails.count(); i++) {
partitionIndexDetails[i].clear();
}
+ for (int i = 0; i < partitionKeyRequestDetails.count(); i++) {
+ partitionKeyRequestDetails[i].clear();
+ }
+
+ for (int i = 0; i < indexRequests.count(); i++) {
+ indexRequests[i]->resetRequest();
+ }
+ for (int i = 0; i < keyRequests.count(); i++) {
+ keyRequests[i]->resetRequest();
+ }
+ for (int i = 0; i < valueRequests.count(); i++) {
+ valueRequests[i]->resetRequest();
+ }
}
for (int i = 0; i < partitionObjects.count(); i++) {
fetchIndexSpec(i);
@@ -1572,9 +1599,8 @@ void QJsonDbQueryModel::setQuery(const QString &newQuery)
return;
d->query = l_query;
- if (rowCount() && d->query.isEmpty()) {
+ if (d->query.isEmpty())
d->reset();
- }
if (!d->componentComplete || d->query.isEmpty() || !d->partitionObjects.count() || !d->partitionsReady())
return;