MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / start

Function start

Telegram/SourceFiles/logs.cpp:354–429  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

352}
353
354void 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

Callers

nothing calls this directly

Calls 15

cForceWorkingDirFunction · 0.85
cExeDirFunction · 0.85
StartCatchingFunction · 0.85
bFunction · 0.85
DebugEnabledFunction · 0.85
cExeNameFunction · 0.85
_logsFilePathFunction · 0.85
MoveOldDataFilesFunction · 0.85
psAppDataPathOldFunction · 0.85
_logsWriteFunction · 0.85
openMainMethod · 0.80

Tested by

no test coverage detected