MCPcopy Create free account
hub / github.com/ElyPrismLauncher/Launcher / executeTask

Method executeTask

launcher/InstanceCreationTask.cpp:24–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22}
23
24void InstanceCreationTask::executeTask()
25{
26 setAbortable(true);
27
28 if (updateInstance()) {
29 emitSucceeded();
30 return;
31 }
32
33 // When the user aborted in the update stage.
34 if (m_abort) {
35 emitAborted();
36 return;
37 }
38
39 m_instance = createInstance();
40 if (!m_instance) {
41 if (m_abort)
42 return;
43
44 qWarning() << "Instance creation failed!";
45 if (!m_error_message.isEmpty()) {
46 qWarning() << "Reason:" << m_error_message;
47 emitFailed(tr("Error while creating new instance:\n%1").arg(m_error_message));
48 } else {
49 emitFailed(tr("Error while creating new instance."));
50 }
51
52 return;
53 }
54
55 // If this is set, it means we're updating an instance. So, we now need to remove the
56 // files scheduled to, and we'd better not let the user abort in the middle of it, since it'd
57 // put the instance in an invalid state.
58 if (shouldOverride()) {
59 bool deleteFailed = false;
60
61 setAbortable(false);
62 setStatus(tr("Removing old conflicting files..."));
63 qDebug() << "Removing old files";
64
65 for (const QString& path : m_filesToRemove) {
66 if (!QFile::exists(path))
67 continue;
68
69 qDebug() << "Removing" << path;
70
71 if (!QFile::remove(path)) {
72 qCritical() << "Could not remove" << path;
73 deleteFailed = true;
74 }
75 }
76
77 if (deleteFailed) {
78 emitFailed(tr("Failed to remove old conflicting files."));
79 return;
80 }
81 }

Callers

nothing calls this directly

Calls 8

removeFunction · 0.85
addTaskMethod · 0.80
wasSuccessfulMethod · 0.80
isEmptyMethod · 0.45
createUpdateTaskMethod · 0.45
getMethod · 0.45
failReasonMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected