| 161 | } |
| 162 | |
| 163 | Application::Application(int &argc, char **argv) : QApplication(argc, argv) |
| 164 | { |
| 165 | #if defined Q_OS_WIN32 |
| 166 | // attach the parent console |
| 167 | if(AttachConsole(ATTACH_PARENT_PROCESS)) |
| 168 | { |
| 169 | // if attach succeeds, reopen and sync all the i/o |
| 170 | if(freopen("CON", "w", stdout)) |
| 171 | { |
| 172 | std::cout.sync_with_stdio(); |
| 173 | } |
| 174 | if(freopen("CON", "w", stderr)) |
| 175 | { |
| 176 | std::cerr.sync_with_stdio(); |
| 177 | } |
| 178 | if(freopen("CON", "r", stdin)) |
| 179 | { |
| 180 | std::cin.sync_with_stdio(); |
| 181 | } |
| 182 | auto out = GetStdHandle (STD_OUTPUT_HANDLE); |
| 183 | DWORD written; |
| 184 | const char * endline = "\n"; |
| 185 | WriteConsole(out, endline, strlen(endline), &written, NULL); |
| 186 | consoleAttached = true; |
| 187 | } |
| 188 | #endif |
| 189 | setOrganizationName(BuildConfig.LAUNCHER_NAME); |
| 190 | setOrganizationDomain(BuildConfig.LAUNCHER_DOMAIN); |
| 191 | setApplicationName(BuildConfig.LAUNCHER_NAME); |
| 192 | setApplicationDisplayName(BuildConfig.LAUNCHER_DISPLAYNAME); |
| 193 | setApplicationVersion(BuildConfig.printableVersionString()); |
| 194 | |
| 195 | startTime = QDateTime::currentDateTime(); |
| 196 | |
| 197 | #ifdef Q_OS_LINUX |
| 198 | { |
| 199 | QFile osrelease("/proc/sys/kernel/osrelease"); |
| 200 | if (osrelease.open(QFile::ReadOnly | QFile::Text)) { |
| 201 | QTextStream in(&osrelease); |
| 202 | auto contents = in.readAll(); |
| 203 | if( |
| 204 | contents.contains("WSL", Qt::CaseInsensitive) || |
| 205 | contents.contains("Microsoft", Qt::CaseInsensitive) |
| 206 | ) { |
| 207 | showFatalErrorMessage( |
| 208 | "Unsupported system detected!", |
| 209 | "Linux-on-Windows distributions are not supported.\n\n" |
| 210 | "Please use the Windows binary when playing on Windows." |
| 211 | ); |
| 212 | return; |
| 213 | } |
| 214 | } |
| 215 | } |
| 216 | #endif |
| 217 | |
| 218 | // Don't quit on hiding the last window |
| 219 | this->setQuitOnLastWindowClosed(false); |
| 220 |
nothing calls this directly
no test coverage detected