1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-02 00:10:22 +02:00

Merge pull request #2761 from IvanSavenko/fix_launcher_freeze

(1.3.2) Fix Launcher freeze on startup
This commit is contained in:
Ivan Savenko 2023-09-07 10:51:09 +03:00 committed by GitHub
commit 4615a4e3ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 18 deletions

View File

@ -192,13 +192,6 @@ void CModListModel::resetRepositories()
endResetModel();
}
void CModListModel::addRepository(QVariantMap data)
{
beginResetModel();
CModList::addRepository(data);
endResetModel();
}
void CModListModel::modChanged(QString modID)
{
int index = modNameToID.indexOf(modID);

View File

@ -61,7 +61,6 @@ public:
/// CModListContainer overrides
void resetRepositories() override;
void reloadRepositories() override;
void addRepository(QVariantMap data) override;
void modChanged(QString modID) override;
QVariant data(const QModelIndex & index, int role) const override;

View File

@ -657,6 +657,7 @@ void CModListView::installFiles(QStringList files)
{
QStringList mods;
QStringList images;
QVector<QVariantMap> repositories;
// TODO: some better way to separate zip's with mods and downloaded repository files
for(QString filename : files)
@ -666,12 +667,12 @@ void CModListView::installFiles(QStringList files)
if(filename.endsWith(".json"))
{
//download and merge additional files
auto repodata = JsonUtils::JsonFromFile(filename).toMap();
if(repodata.value("name").isNull())
auto repoData = JsonUtils::JsonFromFile(filename).toMap();
if(repoData.value("name").isNull())
{
for(const auto & key : repodata.keys())
for(const auto & key : repoData.keys())
{
auto modjson = repodata[key].toMap().value("mod");
auto modjson = repoData[key].toMap().value("mod");
if(!modjson.isNull())
{
downloadFile(key + ".json", modjson.toString(), "repository index");
@ -682,14 +683,17 @@ void CModListView::installFiles(QStringList files)
{
auto modn = QFileInfo(filename).baseName();
QVariantMap temp;
temp[modn] = repodata;
repodata = temp;
temp[modn] = repoData;
repoData = temp;
}
manager->loadRepository(repodata);
repositories.push_back(repoData);
}
if(filename.endsWith(".png"))
images.push_back(filename);
}
manager->loadRepositories(repositories);
if(!mods.empty())
installMods(mods);

View File

@ -68,9 +68,11 @@ void CModManager::resetRepositories()
modList->resetRepositories();
}
void CModManager::loadRepository(QVariantMap repomap)
void CModManager::loadRepositories(QVector<QVariantMap> repomap)
{
modList->addRepository(repomap);
for (auto const & entry : repomap)
modList->addRepository(entry);
modList->reloadRepositories();
}
void CModManager::loadMods()

View File

@ -35,7 +35,7 @@ public:
CModManager(CModList * modList);
void resetRepositories();
void loadRepository(QVariantMap repomap);
void loadRepositories(QVector<QVariantMap> repomap);
void loadModSettings();
void loadMods();