Commit 8c50c5f9 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Make sure the update progress is as smooth as possible

parent f01cd4b0
......@@ -199,7 +199,7 @@ int TransactionModel::progress() const
int sum = 0;
int count = 0;
foreach(Transaction* t, m_transactions) {
if (t->isActive()) {
if (t->isActive() && t->isVisible()) {
sum += t->progress();
++count;
}
......
......@@ -28,6 +28,7 @@
#include <ReviewsBackend/ReviewsModel.h>
#include <UpdateModel/UpdateModel.h>
#include <resources/ResourcesUpdatesModel.h>
#include <Transaction/TransactionModel.h>
#include <qtest.h>
#include <QtTest>
......@@ -107,10 +108,19 @@ private Q_SLOTS:
rum->prepare();
spy.clear();
QCOMPARE(rum->isProgressing(), false);
rum->updateAll();
QVERIFY(spy.count() || spy.wait());
QCOMPARE(rum->isProgressing(), true);
QCOMPARE(TransactionModel::global()->rowCount(), 1);
connect(TransactionModel::global(), &TransactionModel::progressChanged, this, []() {
const int progress = TransactionModel::global()->progress();
static int lastProgress = -1;
Q_ASSERT(progress >= lastProgress || (TransactionModel::global()->rowCount() == 0 && progress == 0));
lastProgress = progress;
});
QTest::qWait(20);
QScopedPointer<ResourcesUpdatesModel> rum2(new ResourcesUpdatesModel(this));
new ModelTest(rum2.data(), rum2.data());
......@@ -119,6 +129,7 @@ private Q_SLOTS:
new ModelTest(m2.data(), m2.data());
m->setBackend(rum2.data());
QCOMPARE(rum->isProgressing(), true);
QVERIFY(spy.wait());
QCOMPARE(rum->isProgressing(), false);
......
......@@ -84,7 +84,6 @@ public:
if (status() < DoneStatus && !isProgressing()) {
setStatus(Transaction::DoneStatus);
Q_EMIT finished();
qDebug() << "finished!" << this << sender();
deleteLater();
}
}
......
......@@ -113,7 +113,7 @@ void StandardBackendUpdater::transactionRemoved(Transaction* t)
void StandardBackendUpdater::refreshUpdateable()
{
if (m_backend->isFetching()) {
if (m_backend->isFetching() || isProgressing()) {
return;
}
......@@ -181,6 +181,8 @@ void StandardBackendUpdater::cleanup()
{
m_lastUpdate = QDateTime::currentDateTime();
m_toUpgrade.clear();
refreshUpdateable();
emit progressingChanged(false);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment