mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-03 20:13:56 -07:00
[SettingsManager] Properly handle multithreaded access again (#6844)
* [SettingsManager] Properly handle multithreaded access again * Add comment * Add batch write function --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
7c9fbe2be0
commit
19dbb17fb9
10 changed files with 88 additions and 12 deletions
|
|
@ -228,16 +228,19 @@ void SetsModel::sort(int column, Qt::SortOrder order)
|
|||
|
||||
void SetsModel::save(CardDatabase *db)
|
||||
{
|
||||
// order
|
||||
for (int i = 0; i < sets.size(); i++)
|
||||
sets[i]->setSortKey(static_cast<unsigned int>(i + 1));
|
||||
QVector<ICardSetPriorityController::SetSaveData> saveData;
|
||||
saveData.reserve(sets.size());
|
||||
|
||||
// enabled sets
|
||||
for (const CardSetPtr &set : sets)
|
||||
set->setEnabled(enabledSets.contains(set));
|
||||
for (int i = 0; i < sets.size(); ++i) {
|
||||
const unsigned int sortKey = static_cast<unsigned int>(i + 1);
|
||||
const bool enabled = enabledSets.contains(sets[i]);
|
||||
sets[i]->setSortKeyInMemory(sortKey);
|
||||
sets[i]->setEnabledInMemory(enabled);
|
||||
saveData.append({sets[i]->getShortName(), sortKey, enabled});
|
||||
}
|
||||
|
||||
db->getPriorityController()->saveSets(saveData);
|
||||
sets.sortByKey();
|
||||
|
||||
db->notifyEnabledSetsChanged();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue