fix: aborts when using a Qt build with assertions enabled

Preventing undefined behaviour hooray! :D

Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
flow 2022-06-24 20:09:44 -03:00
parent 145da82cd8
commit e5f6dc1b14
No known key found for this signature in database
GPG Key ID: 8D0F221F0A59F469
5 changed files with 27 additions and 5 deletions

View File

@ -167,6 +167,9 @@ void ModFolderModel::finishUpdate()
{ {
QSet<QString> added = newSet; QSet<QString> added = newSet;
added.subtract(currentSet); added.subtract(currentSet);
// When you have a Qt build with assertions turned on, proceeding here will abort the application
if (added.size() > 0) {
beginInsertRows(QModelIndex(), mods.size(), mods.size() + added.size() - 1); beginInsertRows(QModelIndex(), mods.size(), mods.size() + added.size() - 1);
for (auto& addedMod : added) { for (auto& addedMod : added) {
mods.append(newMods[addedMod]); mods.append(newMods[addedMod]);
@ -174,6 +177,7 @@ void ModFolderModel::finishUpdate()
} }
endInsertRows(); endInsertRows();
} }
}
// update index // update index
{ {

View File

@ -219,6 +219,10 @@ void ListModel::searchRequestFinished(QJsonDocument& doc)
searchState = CanPossiblyFetchMore; searchState = CanPossiblyFetchMore;
} }
// When you have a Qt build with assertions turned on, proceeding here will abort the application
if (newList.size() == 0)
return;
beginInsertRows(QModelIndex(), modpacks.size(), modpacks.size() + newList.size() - 1); beginInsertRows(QModelIndex(), modpacks.size(), modpacks.size() + newList.size() - 1);
modpacks.append(newList); modpacks.append(newList);
endInsertRows(); endInsertRows();

View File

@ -221,6 +221,11 @@ void Flame::ListModel::searchRequestFinished()
nextSearchOffset += 25; nextSearchOffset += 25;
searchState = CanPossiblyFetchMore; searchState = CanPossiblyFetchMore;
} }
// When you have a Qt build with assertions turned on, proceeding here will abort the application
if (newList.size() == 0)
return;
beginInsertRows(QModelIndex(), modpacks.size(), modpacks.size() + newList.size() - 1); beginInsertRows(QModelIndex(), modpacks.size(), modpacks.size() + newList.size() - 1);
modpacks.append(newList); modpacks.append(newList);
endInsertRows(); endInsertRows();

View File

@ -290,6 +290,10 @@ void ModpackListModel::searchRequestFinished(QJsonDocument& doc_all)
searchState = CanPossiblyFetchMore; searchState = CanPossiblyFetchMore;
} }
// When you have a Qt build with assertions turned on, proceeding here will abort the application
if (newList.size() == 0)
return;
beginInsertRows(QModelIndex(), modpacks.size(), modpacks.size() + newList.size() - 1); beginInsertRows(QModelIndex(), modpacks.size(), modpacks.size() + newList.size() - 1);
modpacks.append(newList); modpacks.append(newList);
endInsertRows(); endInsertRows();

View File

@ -217,6 +217,11 @@ void Technic::ListModel::searchRequestFinished()
return; return;
} }
searchState = Finished; searchState = Finished;
// When you have a Qt build with assertions turned on, proceeding here will abort the application
if (newList.size() == 0)
return;
beginInsertRows(QModelIndex(), modpacks.size(), modpacks.size() + newList.size() - 1); beginInsertRows(QModelIndex(), modpacks.size(), modpacks.size() + newList.size() - 1);
modpacks.append(newList); modpacks.append(newList);
endInsertRows(); endInsertRows();