mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 18:09:59 +03:00
fix(ModFolderPage): preserve profile state synchronization during cleanup
Signed-off-by: Vivek Kushwaha <notvivekkushwaha@gmail.com>
This commit is contained in:
parent
352b45bf5e
commit
8e85ecfd43
4 changed files with 12 additions and 348 deletions
|
|
@ -1,12 +1,6 @@
|
|||
#include "ResourceFolderModel.h"
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <QThread>
|
||||
#include <QAtomicInt>
|
||||
|
||||
extern QAtomicInt g_logSequence;
|
||||
extern QString getActiveProfileForModel(void* modelPtr);
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QFileInfo>
|
||||
|
|
@ -308,29 +302,9 @@ bool ResourceFolderModel::setResourceEnabled(const QModelIndexList& indexes, Ena
|
|||
|
||||
auto& resource = m_resources[row];
|
||||
|
||||
QString originalName = resource->getOriginalFileName();
|
||||
QString oldPath = resource->fileinfo().absoluteFilePath();
|
||||
bool wasEnabled = resource->enabled();
|
||||
|
||||
qDebug() << "[INSTRUMENTATION-MUTATION]" << ++g_logSequence
|
||||
<< "setResourceEnabled() START"
|
||||
<< "resource:" << originalName
|
||||
<< "wasEnabled:" << wasEnabled
|
||||
<< "oldPath:" << oldPath
|
||||
<< "action:" << (action == EnableAction::ENABLE ? "ENABLE" : (action == EnableAction::DISABLE ? "DISABLE" : "TOGGLE"));
|
||||
|
||||
// Preserve the row, but change its ID
|
||||
auto oldId = resource->internalId();
|
||||
bool ok = resource->enable(action);
|
||||
|
||||
qDebug() << "[INSTRUMENTATION-MUTATION]" << ++g_logSequence
|
||||
<< "setResourceEnabled() END"
|
||||
<< "resource:" << originalName
|
||||
<< "nowEnabled:" << resource->enabled()
|
||||
<< "newPath:" << resource->fileinfo().absoluteFilePath()
|
||||
<< "succeeded:" << ok;
|
||||
|
||||
if (!ok) {
|
||||
if (!resource->enable(action)) {
|
||||
succeeded = false;
|
||||
continue;
|
||||
}
|
||||
|
|
@ -340,12 +314,6 @@ bool ResourceFolderModel::setResourceEnabled(const QModelIndexList& indexes, Ena
|
|||
m_resourcesIndex.remove(oldId);
|
||||
m_resourcesIndex[newId] = row;
|
||||
|
||||
qDebug() << "[INSTRUMENTATION]" << ++g_logSequence
|
||||
<< "EMIT dataChanged() (setResourceEnabled)"
|
||||
<< "row:" << row
|
||||
<< "thread:" << QThread::currentThreadId()
|
||||
<< "model:" << this
|
||||
<< "profile:" << getActiveProfileForModel(this);
|
||||
emit dataChanged(index(row, 0), index(row, columnCount(QModelIndex()) - 1));
|
||||
}
|
||||
|
||||
|
|
@ -380,11 +348,6 @@ bool ResourceFolderModel::update()
|
|||
m_scheduledUpdate = false;
|
||||
update();
|
||||
} else {
|
||||
qDebug() << "[INSTRUMENTATION]" << ++g_logSequence
|
||||
<< "EMIT updateFinished()"
|
||||
<< "thread:" << QThread::currentThreadId()
|
||||
<< "model:" << this
|
||||
<< "profile:" << getActiveProfileForModel(this);
|
||||
emit updateFinished();
|
||||
}
|
||||
},
|
||||
|
|
@ -469,12 +432,6 @@ void ResourceFolderModel::onParseSucceeded(int ticket, const QString& resourceId
|
|||
}
|
||||
|
||||
int row = m_resourcesIndex[resourceId];
|
||||
qDebug() << "[INSTRUMENTATION]" << ++g_logSequence
|
||||
<< "EMIT dataChanged() (onParseSucceeded)"
|
||||
<< "row:" << row
|
||||
<< "thread:" << QThread::currentThreadId()
|
||||
<< "model:" << this
|
||||
<< "profile:" << getActiveProfileForModel(this);
|
||||
emit dataChanged(index(row), index(row, columnCount(QModelIndex()) - 1));
|
||||
}
|
||||
|
||||
|
|
@ -899,21 +856,6 @@ void ResourceFolderModel::onParseFailed(int ticket, const QString& resourceId)
|
|||
|
||||
void ResourceFolderModel::applyUpdates(QSet<QString>& currentSet, QSet<QString>& newSet, QMap<QString, Resource::Ptr>& newResources)
|
||||
{
|
||||
{
|
||||
QSet<QString> enabledBefore;
|
||||
for (const auto& res : m_resources) {
|
||||
if (res->enabled()) {
|
||||
enabledBefore.insert(res->getOriginalFileName());
|
||||
}
|
||||
}
|
||||
qDebug() << "[INSTRUMENTATION-APPLYUPDATES] START"
|
||||
<< "seq:" << ++g_logSequence
|
||||
<< "profile:" << getActiveProfileForModel(this)
|
||||
<< "enabledBefore:" << enabledBefore
|
||||
<< "currentSet:" << currentSet
|
||||
<< "newSet:" << newSet;
|
||||
}
|
||||
|
||||
// see if the kept resources changed in some way
|
||||
{
|
||||
QSet<QString> keptSet = currentSet;
|
||||
|
|
@ -933,12 +875,6 @@ void ResourceFolderModel::applyUpdates(QSet<QString>& currentSet, QSet<QString>&
|
|||
currentResource->updateIssues(m_instance);
|
||||
|
||||
if (hadIssues != currentResource->hasIssues()) {
|
||||
qDebug() << "[INSTRUMENTATION]" << ++g_logSequence
|
||||
<< "EMIT dataChanged() (applyUpdates unchanged file)"
|
||||
<< "row:" << row
|
||||
<< "thread:" << QThread::currentThreadId()
|
||||
<< "model:" << this
|
||||
<< "profile:" << getActiveProfileForModel(this);
|
||||
emit dataChanged(index(row, 0), index(row, columnCount({}) - 1));
|
||||
}
|
||||
continue;
|
||||
|
|
@ -958,12 +894,6 @@ void ResourceFolderModel::applyUpdates(QSet<QString>& currentSet, QSet<QString>&
|
|||
newResource->updateIssues(m_instance);
|
||||
|
||||
resolveResource(m_resources.at(row));
|
||||
qDebug() << "[INSTRUMENTATION]" << ++g_logSequence
|
||||
<< "EMIT dataChanged() (applyUpdates changed file)"
|
||||
<< "row:" << row
|
||||
<< "thread:" << QThread::currentThreadId()
|
||||
<< "model:" << this
|
||||
<< "profile:" << getActiveProfileForModel(this);
|
||||
emit dataChanged(index(row, 0), index(row, columnCount(QModelIndex()) - 1));
|
||||
}
|
||||
}
|
||||
|
|
@ -1029,42 +959,6 @@ void ResourceFolderModel::applyUpdates(QSet<QString>& currentSet, QSet<QString>&
|
|||
idx++;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
QSet<QString> enabledAfter;
|
||||
for (const auto& res : m_resources) {
|
||||
if (res->enabled()) {
|
||||
enabledAfter.insert(res->getOriginalFileName());
|
||||
}
|
||||
}
|
||||
|
||||
QSet<QString> keptSet = currentSet;
|
||||
keptSet.intersect(newSet);
|
||||
QSet<QString> removedSet = currentSet;
|
||||
removedSet.subtract(newSet);
|
||||
QSet<QString> addedSet = newSet;
|
||||
addedSet.subtract(currentSet);
|
||||
|
||||
qDebug() << "[INSTRUMENTATION-APPLYUPDATES] END"
|
||||
<< "seq:" << ++g_logSequence
|
||||
<< "profile:" << getActiveProfileForModel(this)
|
||||
<< "enabledAfter:" << enabledAfter
|
||||
<< "added:" << addedSet
|
||||
<< "removed:" << removedSet;
|
||||
for (const auto& kept : keptSet) {
|
||||
auto rowIt = m_resourcesIndex.constFind(kept);
|
||||
if (rowIt != m_resourcesIndex.constEnd()) {
|
||||
auto row = rowIt.value();
|
||||
auto& newResource = newResources[kept];
|
||||
const auto& currentResource = m_resources.at(row);
|
||||
if (newResource->enabled() != currentResource->enabled()) {
|
||||
qDebug() << " -> kept resource changed enabled state:" << kept
|
||||
<< "before:" << currentResource->enabled()
|
||||
<< "after:" << newResource->enabled();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Resource::Ptr ResourceFolderModel::find(QString id)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue