moved QEventLoops inside functions
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
06e1cab41f
commit
0a95b57c0a
@ -149,4 +149,14 @@ Task::Ptr Index::loadVersion(const QString& uid, const QString& version, Net::Mo
|
|||||||
loadTask->addTask(versionList->getVersion(version)->loadTask(mode));
|
loadTask->addTask(versionList->getVersion(version)->loadTask(mode));
|
||||||
return loadTask;
|
return loadTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Version::Ptr Index::getLoadedVersion(const QString& uid, const QString& version)
|
||||||
|
{
|
||||||
|
QEventLoop ev;
|
||||||
|
auto task = loadVersion(uid, version);
|
||||||
|
QObject::connect(task.get(), &Task::finished, &ev, &QEventLoop::quit);
|
||||||
|
task->start();
|
||||||
|
ev.exec();
|
||||||
|
return get(uid, version);
|
||||||
|
}
|
||||||
} // namespace Meta
|
} // namespace Meta
|
||||||
|
@ -50,6 +50,9 @@ class Index : public QAbstractListModel, public BaseEntity {
|
|||||||
|
|
||||||
Task::Ptr loadVersion(const QString& uid, const QString& version = {}, Net::Mode mode = Net::Mode::Online, bool force = false);
|
Task::Ptr loadVersion(const QString& uid, const QString& version = {}, Net::Mode mode = Net::Mode::Online, bool force = false);
|
||||||
|
|
||||||
|
// this blocks until the version is loaded
|
||||||
|
Version::Ptr getLoadedVersion(const QString& uid, const QString& version);
|
||||||
|
|
||||||
public: // for usage by parsers only
|
public: // for usage by parsers only
|
||||||
void merge(const std::shared_ptr<Index>& other);
|
void merge(const std::shared_ptr<Index>& other);
|
||||||
|
|
||||||
|
@ -254,4 +254,14 @@ BaseVersion::Ptr VersionList::getRecommended() const
|
|||||||
return m_recommended;
|
return m_recommended;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VersionList::waitToLoad()
|
||||||
|
{
|
||||||
|
if (isLoaded())
|
||||||
|
return;
|
||||||
|
QEventLoop ev;
|
||||||
|
auto task = getLoadTask();
|
||||||
|
QObject::connect(task.get(), &Task::finished, &ev, &QEventLoop::quit);
|
||||||
|
task->start();
|
||||||
|
ev.exec();
|
||||||
|
}
|
||||||
} // namespace Meta
|
} // namespace Meta
|
||||||
|
@ -59,6 +59,9 @@ class VersionList : public BaseVersionList, public BaseEntity {
|
|||||||
|
|
||||||
QVector<Version::Ptr> versions() const { return m_versions; }
|
QVector<Version::Ptr> versions() const { return m_versions; }
|
||||||
|
|
||||||
|
// this blocks until the version list is loaded
|
||||||
|
void waitToLoad();
|
||||||
|
|
||||||
public: // for usage only by parsers
|
public: // for usage only by parsers
|
||||||
void setName(const QString& name);
|
void setName(const QString& name);
|
||||||
void setVersions(const QVector<Version::Ptr>& versions);
|
void setVersions(const QVector<Version::Ptr>& versions);
|
||||||
|
@ -91,11 +91,8 @@ std::shared_ptr<class VersionFile> Component::getVersionFile() const
|
|||||||
{
|
{
|
||||||
if (m_metaVersion) {
|
if (m_metaVersion) {
|
||||||
if (!m_metaVersion->isLoaded()) {
|
if (!m_metaVersion->isLoaded()) {
|
||||||
QEventLoop ev;
|
// this method is const but the loading of meta changes the information
|
||||||
auto task = APPLICATION->metadataIndex()->loadVersion(m_metaVersion->uid(), m_metaVersion->version(), Net::Mode::Online);
|
APPLICATION->metadataIndex()->getLoadedVersion(m_metaVersion->uid(), m_metaVersion->version());
|
||||||
connect(task.get(), &Task::finished, &ev, &QEventLoop::quit);
|
|
||||||
task->start();
|
|
||||||
ev.exec();
|
|
||||||
}
|
}
|
||||||
return m_metaVersion->data();
|
return m_metaVersion->data();
|
||||||
} else {
|
} else {
|
||||||
@ -197,10 +194,12 @@ bool Component::isCustomizable()
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Component::isRemovable()
|
bool Component::isRemovable()
|
||||||
{
|
{
|
||||||
return !m_important;
|
return !m_important;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Component::isRevertible()
|
bool Component::isRevertible()
|
||||||
{
|
{
|
||||||
if (isCustom()) {
|
if (isCustom()) {
|
||||||
@ -210,22 +209,18 @@ bool Component::isRevertible()
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Component::isMoveable()
|
bool Component::isMoveable()
|
||||||
{
|
{
|
||||||
// HACK, FIXME: this was too dumb and wouldn't follow dependency constraints anyway. For now hardcoded to 'true'.
|
// HACK, FIXME: this was too dumb and wouldn't follow dependency constraints anyway. For now hardcoded to 'true'.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Component::isVersionChangeable()
|
bool Component::isVersionChangeable()
|
||||||
{
|
{
|
||||||
auto list = getVersionList();
|
auto list = getVersionList();
|
||||||
if (list) {
|
if (list) {
|
||||||
if (!list->isLoaded()) {
|
list->waitToLoad();
|
||||||
QEventLoop ev;
|
|
||||||
auto task = list->getLoadTask();
|
|
||||||
connect(task.get(), &Task::finished, &ev, &QEventLoop::quit);
|
|
||||||
task->start();
|
|
||||||
ev.exec();
|
|
||||||
}
|
|
||||||
return list->count() != 0;
|
return list->count() != 0;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -36,7 +36,6 @@
|
|||||||
|
|
||||||
#include "ATLPackInstallTask.h"
|
#include "ATLPackInstallTask.h"
|
||||||
|
|
||||||
#include <QEventLoop>
|
|
||||||
#include <QtConcurrent>
|
#include <QtConcurrent>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
@ -344,13 +343,7 @@ QString PackInstallTask::getVersionForLoader(QString uid)
|
|||||||
return Q_NULLPTR;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vlist->isLoaded()) {
|
vlist->waitToLoad();
|
||||||
QEventLoop ev;
|
|
||||||
auto task = vlist->getLoadTask();
|
|
||||||
connect(task.get(), &Task::finished, &ev, &QEventLoop::quit);
|
|
||||||
task->start();
|
|
||||||
ev.exec();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_version.loader.recommended || m_version.loader.latest) {
|
if (m_version.loader.recommended || m_version.loader.latest) {
|
||||||
for (int i = 0; i < vlist->versions().size(); i++) {
|
for (int i = 0; i < vlist->versions().size(); i++) {
|
||||||
@ -1076,13 +1069,7 @@ void PackInstallTask::install()
|
|||||||
|
|
||||||
static Meta::Version::Ptr getComponentVersion(const QString& uid, const QString& version)
|
static Meta::Version::Ptr getComponentVersion(const QString& uid, const QString& version)
|
||||||
{
|
{
|
||||||
QEventLoop ev;
|
return APPLICATION->metadataIndex()->getLoadedVersion(uid, version);
|
||||||
auto task = APPLICATION->metadataIndex()->loadVersion(uid, version);
|
|
||||||
QObject::connect(task.get(), &Task::finished, &ev, &QEventLoop::quit);
|
|
||||||
task->start();
|
|
||||||
ev.exec();
|
|
||||||
|
|
||||||
return APPLICATION->metadataIndex()->get(uid, version);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ATLauncher
|
} // namespace ATLauncher
|
||||||
|
Loading…
Reference in New Issue
Block a user