summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDominik Holland <dominik.holland@pelagicore.com>2019-03-01 11:07:05 +0100
committerDominik Holland <dominik.holland@pelagicore.com>2019-03-08 12:04:49 +0000
commit8bc29da8b94d929b9c59f2516c1013372263b48f (patch)
treea8600f151fe1c8335850a9d6e7d51eb125dd8b12 /src
parent65e47f6a308c9ea316160806788d7b7324923c6d (diff)
downloadqtivi-8bc29da8b94d929b9c59f2516c1013372263b48f.tar.gz
QIviPagingModel: Start to fetch the content after the initialization is done
Previously we didn't wait for the initialization to be done and called our register and fetch functions directly after calling init(). This can lead to problems as the backend might not be fully ready at this point of time. Change-Id: Icfc91faed30892f6a14494c3ec17b74376ae337b Reviewed-by: Robert Griebl <robert.griebl@pelagicore.com>
Diffstat (limited to 'src')
-rw-r--r--src/ivicore/qivipagingmodel.cpp19
-rw-r--r--src/ivicore/qivipagingmodel_p.h1
2 files changed, 16 insertions, 4 deletions
diff --git a/src/ivicore/qivipagingmodel.cpp b/src/ivicore/qivipagingmodel.cpp
index b5dd312..99d4bad 100644
--- a/src/ivicore/qivipagingmodel.cpp
+++ b/src/ivicore/qivipagingmodel.cpp
@@ -88,6 +88,19 @@ void QIviPagingModelPrivate::initialize()
this, &QIviPagingModelPrivate::onFetchMoreThresholdReached);
}
+void QIviPagingModelPrivate::onInitializationDone()
+{
+ Q_Q(QIviPagingModel);
+
+ if (q->isInitialized())
+ return;
+
+ //Register this instance with the backend. The backend can initialize the internal structure now
+ backend()->registerInstance(m_identifier);
+
+ resetModel();
+}
+
void QIviPagingModelPrivate::onCapabilitiesChanged(const QUuid &identifier, QtIviCoreModule::ModelCapabilities capabilities)
{
if (!identifier.isNull() && identifier != m_identifier)
@@ -741,6 +754,8 @@ void QIviPagingModel::connectToServiceObject(QIviServiceObject *serviceObject)
if (!backend)
return;
+ QObjectPrivate::connect(backend, &QIviPagingModelInterface::initializationDone,
+ d, &QIviPagingModelPrivate::onInitializationDone);
QObjectPrivate::connect(backend, &QIviPagingModelInterface::supportedCapabilitiesChanged,
d, &QIviPagingModelPrivate::onCapabilitiesChanged);
QObjectPrivate::connect(backend, &QIviPagingModelInterface::dataFetched,
@@ -751,10 +766,6 @@ void QIviPagingModel::connectToServiceObject(QIviServiceObject *serviceObject)
d, &QIviPagingModelPrivate::onDataChanged);
QIviAbstractFeatureListModel::connectToServiceObject(serviceObject);
- //Register this instance with the backend. The backend can initialize the internal structure now
- backend->registerInstance(d->m_identifier);
-
- d->resetModel();
}
/*!
diff --git a/src/ivicore/qivipagingmodel_p.h b/src/ivicore/qivipagingmodel_p.h
index d3517c4..babce20 100644
--- a/src/ivicore/qivipagingmodel_p.h
+++ b/src/ivicore/qivipagingmodel_p.h
@@ -73,6 +73,7 @@ public:
~QIviPagingModelPrivate() override;
void initialize() override;
+ void onInitializationDone();
void onCapabilitiesChanged(const QUuid &identifier, QtIviCoreModule::ModelCapabilities capabilities);
void onDataFetched(const QUuid &identifier, const QList<QVariant> &items, int start, bool moreAvailable);
void onCountChanged(const QUuid &identifier, int new_length);