| 352 | } |
| 353 | |
| 354 | void start() { |
| 355 | Assert(LogsData == nullptr); |
| 356 | |
| 357 | auto &launcher = Core::Launcher::Instance(); |
| 358 | if (!launcher.checkPortableVersionFolder()) { |
| 359 | return; |
| 360 | } |
| 361 | |
| 362 | LogsData = new LogsDataFields(); |
| 363 | if (cWorkingDir().isEmpty()) { |
| 364 | #if (!defined Q_OS_WIN && !defined _DEBUG) || defined Q_OS_WINRT || defined OS_WIN_STORE || defined OS_MAC_STORE |
| 365 | cForceWorkingDir(psAppDataPath()); |
| 366 | #else // (!Q_OS_WIN && !_DEBUG) || Q_OS_WINRT || OS_WIN_STORE || OS_MAC_STORE |
| 367 | cForceWorkingDir(cExeDir()); |
| 368 | if (!LogsData->openMain()) { |
| 369 | cForceWorkingDir(psAppDataPath()); |
| 370 | } |
| 371 | #endif // (!Q_OS_WIN && !_DEBUG) || Q_OS_WINRT || OS_WIN_STORE || OS_MAC_STORE |
| 372 | } |
| 373 | |
| 374 | if (launcher.validateCustomWorkingDir()) { |
| 375 | delete LogsData; |
| 376 | LogsData = new LogsDataFields(); |
| 377 | } |
| 378 | |
| 379 | // WinRT build requires the working dir to stay the same for plugin loading. |
| 380 | #ifndef Q_OS_WINRT |
| 381 | QDir::setCurrent(cWorkingDir()); |
| 382 | #endif // !Q_OS_WINRT |
| 383 | |
| 384 | QDir().mkpath(cWorkingDir() + u"tdata"_q); |
| 385 | |
| 386 | launcher.workingFolderReady(); |
| 387 | CrashReports::StartCatching(); |
| 388 | |
| 389 | if (!LogsData->openMain()) { |
| 390 | delete LogsData; |
| 391 | LogsData = nullptr; |
| 392 | } |
| 393 | |
| 394 | LOG(("Launched version: %1, install beta: %2, alpha: %3, debug mode: %4" |
| 395 | ).arg(AppVersion |
| 396 | ).arg(Logs::b(cInstallBetaVersion()) |
| 397 | ).arg(cAlphaVersion() |
| 398 | ).arg(Logs::b(DebugEnabled()))); |
| 399 | LOG(("Executable dir: %1, name: %2").arg(cExeDir(), cExeName())); |
| 400 | LOG(("Initial working dir: %1").arg(launcher.initialWorkingDir())); |
| 401 | LOG(("Working dir: %1").arg(cWorkingDir())); |
| 402 | LOG(("Command line: %1").arg(launcher.arguments().join(' '))); |
| 403 | |
| 404 | if (!LogsData) { |
| 405 | LOG(("FATAL: Could not open '%1' for writing log!" |
| 406 | ).arg(_logsFilePath(LogDataMain, u"_startXX"_q))); |
| 407 | return; |
| 408 | } |
| 409 | |
| 410 | #ifdef Q_OS_WIN |
| 411 | if (cWorkingDir() == psAppDataPath()) { // fix old "Telegram Win (Unofficial)" version |
nothing calls this directly
no test coverage detected