mirror of
https://github.com/MultiMC/MultiMC5.git
synced 2024-09-03 21:49:13 +00:00
GH-1015 catch exceptions when doing profile reapply
This is a temporary solution.
This commit is contained in:
parent
b9e06b5da0
commit
99f248ecd4
@ -22,6 +22,7 @@
|
||||
#include "minecraft/MinecraftProfile.h"
|
||||
#include "ProfileUtils.h"
|
||||
#include "NullProfileStrategy.h"
|
||||
#include "VersionBuildError.h"
|
||||
|
||||
MinecraftProfile::MinecraftProfile(ProfileStrategy *strategy)
|
||||
: QAbstractListModel()
|
||||
@ -52,7 +53,7 @@ void MinecraftProfile::reload()
|
||||
{
|
||||
beginResetModel();
|
||||
m_strategy->load();
|
||||
reapply();
|
||||
reapplySafe();
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
@ -109,7 +110,7 @@ bool MinecraftProfile::remove(const int index)
|
||||
beginRemoveRows(QModelIndex(), index, index);
|
||||
VersionPatches.removeAt(index);
|
||||
endRemoveRows();
|
||||
reapply();
|
||||
reapplySafe();
|
||||
saveCurrentOrder();
|
||||
return true;
|
||||
}
|
||||
@ -141,7 +142,7 @@ bool MinecraftProfile::customize(int index)
|
||||
qCritical() << "Patch" << patch->getPatchID() << "could not be customized";
|
||||
return false;
|
||||
}
|
||||
reapply();
|
||||
reapplySafe();
|
||||
saveCurrentOrder();
|
||||
// FIXME: maybe later in unstable
|
||||
// emit dataChanged(createIndex(index, 0), createIndex(index, columnCount(QModelIndex()) - 1));
|
||||
@ -161,7 +162,7 @@ bool MinecraftProfile::revert(int index)
|
||||
qCritical() << "Patch" << patch->getPatchID() << "could not be reverted";
|
||||
return false;
|
||||
}
|
||||
reapply();
|
||||
reapplySafe();
|
||||
saveCurrentOrder();
|
||||
// FIXME: maybe later in unstable
|
||||
// emit dataChanged(createIndex(index, 0), createIndex(index, columnCount(QModelIndex()) - 1));
|
||||
@ -221,13 +222,13 @@ bool MinecraftProfile::revertToVanilla()
|
||||
if(!remove(it->getPatchID()))
|
||||
{
|
||||
qWarning() << "Couldn't remove" << it->getPatchID() << "from profile!";
|
||||
reapply();
|
||||
reapplySafe();
|
||||
saveCurrentOrder();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
reapply();
|
||||
reapplySafe();
|
||||
saveCurrentOrder();
|
||||
return true;
|
||||
}
|
||||
@ -398,8 +399,8 @@ void MinecraftProfile::move(const int index, const MoveDirection direction)
|
||||
beginMoveRows(QModelIndex(), index, index, QModelIndex(), togap);
|
||||
VersionPatches.swap(index, theirIndex);
|
||||
endMoveRows();
|
||||
reapplySafe();
|
||||
saveCurrentOrder();
|
||||
reapply();
|
||||
}
|
||||
void MinecraftProfile::resetOrder()
|
||||
{
|
||||
@ -417,6 +418,21 @@ void MinecraftProfile::reapply()
|
||||
finalize();
|
||||
}
|
||||
|
||||
bool MinecraftProfile::reapplySafe()
|
||||
{
|
||||
try
|
||||
{
|
||||
reapply();
|
||||
}
|
||||
catch(MMCError & error)
|
||||
{
|
||||
clear();
|
||||
qWarning() << "Couldn't apply profile patches because: " << error.cause();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void MinecraftProfile::finalize()
|
||||
{
|
||||
// HACK: deny april fools. my head hurts enough already.
|
||||
|
@ -82,9 +82,12 @@ public:
|
||||
/// clear the profile
|
||||
void clear();
|
||||
|
||||
/// apply the patches
|
||||
/// apply the patches. Throws all sorts of errors.
|
||||
void reapply();
|
||||
|
||||
/// apply the patches. Catches all the errors and returns true/false for success/failure
|
||||
bool reapplySafe();
|
||||
|
||||
/// do a finalization step (should always be done after applying all patches to profile)
|
||||
void finalize();
|
||||
|
||||
|
@ -389,14 +389,7 @@ bool OneSixProfileStrategy::installJarMods(QStringList filepaths)
|
||||
profile->appendPatch(f);
|
||||
}
|
||||
profile->saveCurrentOrder();
|
||||
try
|
||||
{
|
||||
profile->reapply();
|
||||
}
|
||||
catch (VersionIncomplete &error)
|
||||
{
|
||||
qDebug() << "Version was incomplete:" << error.cause();
|
||||
}
|
||||
profile->reapplySafe();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user