diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2010-03-12 01:25:43 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2010-03-12 01:25:43 (GMT) |
commit | 6936b5b2a1078a591d0bc5f2e49411c52156eb3d (patch) | |
tree | db7b5911bbfab469cbf95b1400ff8084caaba002 /src/declarative | |
parent | 8d8eee3821a5ae25516a17db2ccc1ca7ec614485 (diff) | |
download | Qt-6936b5b2a1078a591d0bc5f2e49411c52156eb3d.zip Qt-6936b5b2a1078a591d0bc5f2e49411c52156eb3d.tar.gz Qt-6936b5b2a1078a591d0bc5f2e49411c52156eb3d.tar.bz2 |
Revert "Use one thread for all instances."
This reverts commit d4abbfdd1959a65ecfb997c962aa8ea132c77eaf.
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/util/qdeclarativexmllistmodel.cpp | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp index 249880e..01ae2ed 100644 --- a/src/declarative/util/qdeclarativexmllistmodel.cpp +++ b/src/declarative/util/qdeclarativexmllistmodel.cpp @@ -61,6 +61,9 @@ QT_BEGIN_NAMESPACE + + + typedef QPair<int, int> QDeclarativeXmlListRange; /*! @@ -111,6 +114,9 @@ class QDeclarativeXmlQuery : public QThread { Q_OBJECT public: + QDeclarativeXmlQuery(QObject *parent=0) + : QThread(parent), m_quit(false), m_restart(false), m_abort(false), m_queryId(0) { + } ~QDeclarativeXmlQuery() { m_mutex.lock(); m_quit = true; @@ -120,11 +126,6 @@ public: wait(); } - static QDeclarativeXmlQuery *instance() { - static QDeclarativeXmlQuery *query = new QDeclarativeXmlQuery; - return query; - } - void abort() { QMutexLocker locker(&m_mutex); m_abort = true; @@ -163,11 +164,6 @@ public: return m_removedItemRanges; } -private: - QDeclarativeXmlQuery(QObject *parent=0) - : QThread(parent), m_quit(false), m_restart(false), m_abort(false), m_queryId(0) { - } - Q_SIGNALS: void queryCompleted(int queryId, int size); @@ -217,8 +213,6 @@ private: QList<QDeclarativeXmlListRange> m_removedItemRanges; }; -//Q_GLOBAL_STATIC(QDeclarativeXmlQuery, QDeclarativeXmlQuery::instance()); - void QDeclarativeXmlQuery::doQueryJob() { QString r; @@ -410,6 +404,7 @@ public: QNetworkReply *reply; QDeclarativeXmlListModel::Status status; qreal progress; + QDeclarativeXmlQuery qmlXmlQuery; int queryId; QList<QDeclarativeXmlListModelRole *> roleObjects; static void append_role(QDeclarativeListProperty<QDeclarativeXmlListModelRole> *list, QDeclarativeXmlListModelRole *role); @@ -494,7 +489,8 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty<QDecla QDeclarativeXmlListModel::QDeclarativeXmlListModel(QObject *parent) : QListModelInterface(*(new QDeclarativeXmlListModelPrivate), parent) { - connect(QDeclarativeXmlQuery::instance(), SIGNAL(queryCompleted(int,int)), + Q_D(QDeclarativeXmlListModel); + connect(&d->qmlXmlQuery, SIGNAL(queryCompleted(int,int)), this, SLOT(queryCompleted(int,int))); } @@ -727,7 +723,7 @@ void QDeclarativeXmlListModel::reload() if (!d->isComponentComplete) return; - QDeclarativeXmlQuery::instance()->abort(); + d->qmlXmlQuery.abort(); d->queryId = -1; int count = d->size; @@ -759,7 +755,7 @@ void QDeclarativeXmlListModel::reload() } if (!d->xml.isEmpty()) { - d->queryId = QDeclarativeXmlQuery::instance()->doQuery(d->query, d->namespaces, d->xml.toUtf8(), &d->roleObjects); + d->queryId = d->qmlXmlQuery.doQuery(d->query, d->namespaces, d->xml.toUtf8(), &d->roleObjects); d->progress = 1.0; d->status = Ready; emit progressChanged(d->progress); @@ -806,7 +802,7 @@ void QDeclarativeXmlListModel::requestFinished() } else { d->status = Ready; QByteArray data = d->reply->readAll(); - d->queryId = QDeclarativeXmlQuery::instance()->doQuery(d->query, d->namespaces, data, &d->roleObjects); + d->queryId = d->qmlXmlQuery.doQuery(d->query, d->namespaces, data, &d->roleObjects); disconnect(d->reply, 0, this, 0); d->reply->deleteLater(); d->reply = 0; @@ -832,10 +828,10 @@ void QDeclarativeXmlListModel::queryCompleted(int id, int size) return; bool sizeChanged = size != d->size; d->size = size; - d->data = QDeclarativeXmlQuery::instance()->modelData(); + d->data = d->qmlXmlQuery.modelData(); - QList<QDeclarativeXmlListRange> removed = QDeclarativeXmlQuery::instance()->removedItemRanges(); - QList<QDeclarativeXmlListRange> inserted = QDeclarativeXmlQuery::instance()->insertedItemRanges(); + QList<QDeclarativeXmlListRange> removed = d->qmlXmlQuery.removedItemRanges(); + QList<QDeclarativeXmlListRange> inserted = d->qmlXmlQuery.insertedItemRanges(); for (int i=0; i<removed.count(); i++) emit itemsRemoved(removed[i].first, removed[i].second); |