| 94 | } |
| 95 | |
| 96 | void LauncherPartLaunch::executeTask() |
| 97 | { |
| 98 | QString jarPath = APPLICATION->getJarPath("NewLaunch.jar"); |
| 99 | if (jarPath.isEmpty()) |
| 100 | { |
| 101 | const char *reason = QT_TR_NOOP("Launcher library could not be found. Please check your installation."); |
| 102 | emit logLine(tr(reason), MessageLevel::Fatal); |
| 103 | emitFailed(tr(reason)); |
| 104 | return; |
| 105 | } |
| 106 | |
| 107 | auto instance = m_parent->instance(); |
| 108 | std::shared_ptr<MinecraftInstance> minecraftInstance = std::dynamic_pointer_cast<MinecraftInstance>(instance); |
| 109 | |
| 110 | m_launchScript = minecraftInstance->createLaunchScript(m_session, m_serverToJoin); |
| 111 | QStringList args = minecraftInstance->javaArguments(); |
| 112 | QString allArgs = args.join(", "); |
| 113 | emit logLine("Java Arguments:\n[" + m_parent->censorPrivateInfo(allArgs) + "]\n\n", MessageLevel::Launcher); |
| 114 | |
| 115 | auto javaPath = FS::ResolveExecutable(instance->settings()->get("JavaPath").toString()); |
| 116 | |
| 117 | m_process.setProcessEnvironment(instance->createLaunchEnvironment()); |
| 118 | |
| 119 | // make detachable - this will keep the process running even if the object is destroyed |
| 120 | m_process.setDetachable(true); |
| 121 | |
| 122 | auto classPath = minecraftInstance->getClassPath(); |
| 123 | classPath.prepend(jarPath); |
| 124 | |
| 125 | auto natPath = minecraftInstance->getNativePath(); |
| 126 | #ifdef Q_OS_WIN |
| 127 | if (!fitsInLocal8bit(natPath)) |
| 128 | { |
| 129 | args << "-Djava.library.path=" + shortPathName(natPath); |
| 130 | } |
| 131 | else |
| 132 | { |
| 133 | args << "-Djava.library.path=" + natPath; |
| 134 | } |
| 135 | #else |
| 136 | args << "-Djava.library.path=" + natPath; |
| 137 | #endif |
| 138 | |
| 139 | args << "-cp"; |
| 140 | #ifdef Q_OS_WIN |
| 141 | QStringList processed; |
| 142 | for(auto & item: classPath) |
| 143 | { |
| 144 | if (!fitsInLocal8bit(item)) |
| 145 | { |
| 146 | processed << shortPathName(item); |
| 147 | } |
| 148 | else |
| 149 | { |
| 150 | processed << item; |
| 151 | } |
| 152 | } |
| 153 | args << processed.join(';'); |
nothing calls this directly
no test coverage detected