185 { |
185 { |
186 Sync *s = new Sync; |
186 Sync *s = new Sync; |
187 s->data = data; |
187 s->data = data; |
188 s->list = m_copy; |
188 s->list = m_copy; |
189 data.changes.clear(); |
189 data.changes.clear(); |
|
190 |
|
191 mutex.lock(); |
190 QCoreApplication::postEvent(this, s); |
192 QCoreApplication::postEvent(this, s); |
|
193 syncDone.wait(&mutex); |
|
194 mutex.unlock(); |
191 } |
195 } |
192 |
196 |
193 bool QDeclarativeListModelWorkerAgent::event(QEvent *e) |
197 bool QDeclarativeListModelWorkerAgent::event(QEvent *e) |
194 { |
198 { |
195 if (e->type() == QEvent::User) { |
199 if (e->type() == QEvent::User) { |
|
200 QMutexLocker locker(&mutex); |
196 Sync *s = static_cast<Sync *>(e); |
201 Sync *s = static_cast<Sync *>(e); |
197 |
202 |
198 const QList<Change> &changes = s->data.changes; |
203 const QList<Change> &changes = s->data.changes; |
199 |
204 |
200 if (m_copy) { |
205 if (m_copy) { |
201 bool cc = m_copy->count() != s->list->count(); |
206 bool cc = m_copy->count() != s->list->count(); |
202 |
207 |
203 FlatListModel *orig = m_orig->m_flat; |
208 FlatListModel *orig = m_orig->m_flat; |
204 FlatListModel *copy = s->list->m_flat; |
209 FlatListModel *copy = s->list->m_flat; |
205 if (!orig || !copy) |
210 if (!orig || !copy) { |
|
211 syncDone.wakeAll(); |
206 return QObject::event(e); |
212 return QObject::event(e); |
207 |
213 } |
|
214 |
208 orig->m_roles = copy->m_roles; |
215 orig->m_roles = copy->m_roles; |
209 orig->m_strings = copy->m_strings; |
216 orig->m_strings = copy->m_strings; |
210 orig->m_values = copy->m_values; |
217 orig->m_values = copy->m_values; |
|
218 |
|
219 syncDone.wakeAll(); |
|
220 locker.unlock(); |
211 |
221 |
212 for (int ii = 0; ii < changes.count(); ++ii) { |
222 for (int ii = 0; ii < changes.count(); ++ii) { |
213 const Change &change = changes.at(ii); |
223 const Change &change = changes.at(ii); |
214 switch (change.type) { |
224 switch (change.type) { |
215 case Change::Inserted: |
225 case Change::Inserted: |