fix: retry mod search job after aborting it
This way, we don't get stuck with an aborted job in our way! :o Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
parent
224304813a
commit
b638a6ae95
@ -15,6 +15,7 @@ void NetworkModAPI::searchMods(CallerType* caller, SearchArgs&& args) const
|
|||||||
|
|
||||||
QObject::connect(netJob, &NetJob::started, caller, [caller, netJob] { caller->setActiveJob(netJob); });
|
QObject::connect(netJob, &NetJob::started, caller, [caller, netJob] { caller->setActiveJob(netJob); });
|
||||||
QObject::connect(netJob, &NetJob::failed, caller, &CallerType::searchRequestFailed);
|
QObject::connect(netJob, &NetJob::failed, caller, &CallerType::searchRequestFailed);
|
||||||
|
QObject::connect(netJob, &NetJob::aborted, caller, &CallerType::searchRequestAborted);
|
||||||
QObject::connect(netJob, &NetJob::succeeded, caller, [caller, response] {
|
QObject::connect(netJob, &NetJob::succeeded, caller, [caller, response] {
|
||||||
QJsonParseError parse_error{};
|
QJsonParseError parse_error{};
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(*response, &parse_error);
|
QJsonDocument doc = QJsonDocument::fromJson(*response, &parse_error);
|
||||||
|
@ -267,18 +267,25 @@ void ListModel::searchRequestFailed(QString reason)
|
|||||||
.arg(m_parent->displayName())
|
.arg(m_parent->displayName())
|
||||||
.arg(tr("API version too old!\nPlease update %1!").arg(BuildConfig.LAUNCHER_DISPLAYNAME)));
|
.arg(tr("API version too old!\nPlease update %1!").arg(BuildConfig.LAUNCHER_DISPLAYNAME)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jobPtr.reset();
|
||||||
|
searchState = Finished;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ListModel::searchRequestAborted()
|
||||||
|
{
|
||||||
|
if (searchState != ResetRequested)
|
||||||
|
qCritical() << "Search task in ModModel aborted by an unknown reason!";
|
||||||
|
|
||||||
|
// Retry fetching
|
||||||
jobPtr.reset();
|
jobPtr.reset();
|
||||||
|
|
||||||
if (searchState == ResetRequested) {
|
beginResetModel();
|
||||||
beginResetModel();
|
modpacks.clear();
|
||||||
modpacks.clear();
|
endResetModel();
|
||||||
endResetModel();
|
|
||||||
|
|
||||||
nextSearchOffset = 0;
|
nextSearchOffset = 0;
|
||||||
performPaginatedSearch();
|
performPaginatedSearch();
|
||||||
} else {
|
|
||||||
searchState = Finished;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListModel::infoRequestFinished(QJsonDocument& doc, ModPlatform::IndexedPack& pack, const QModelIndex& index)
|
void ListModel::infoRequestFinished(QJsonDocument& doc, ModPlatform::IndexedPack& pack, const QModelIndex& index)
|
||||||
|
@ -51,6 +51,7 @@ class ListModel : public QAbstractListModel {
|
|||||||
public slots:
|
public slots:
|
||||||
void searchRequestFinished(QJsonDocument& doc);
|
void searchRequestFinished(QJsonDocument& doc);
|
||||||
void searchRequestFailed(QString reason);
|
void searchRequestFailed(QString reason);
|
||||||
|
void searchRequestAborted();
|
||||||
|
|
||||||
void infoRequestFinished(QJsonDocument& doc, ModPlatform::IndexedPack& pack, const QModelIndex& index);
|
void infoRequestFinished(QJsonDocument& doc, ModPlatform::IndexedPack& pack, const QModelIndex& index);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user