| 473 | } |
| 474 | |
| 475 | void |
| 476 | CallbacksManager::initInternal() |
| 477 | { |
| 478 | #ifdef NATRON_USE_BREAKPAD |
| 479 | bool enableBreakpad = true; |
| 480 | #else |
| 481 | bool enableBreakpad = false; |
| 482 | #endif |
| 483 | |
| 484 | /* |
| 485 | Check the value of the "Enable crash reports" parameter of the preferences of Natron |
| 486 | */ |
| 487 | QSettings settings( QString::fromUtf8(NATRON_ORGANIZATION_NAME), QString::fromUtf8(NATRON_APPLICATION_NAME) ); |
| 488 | if ( settings.contains( QString::fromUtf8("enableCrashReports") ) ) { |
| 489 | bool userEnableCrashReports = settings.value( QString::fromUtf8("enableCrashReports") ).toBool(); |
| 490 | if (!userEnableCrashReports) { |
| 491 | enableBreakpad = false; |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | // Note it is very important to pass a reference to _argc to QCoreApplication and that this int lives |
| 496 | // thoughout the lifetime of QCoreApplication because it holds a reference to this int the whole time. |
| 497 | QCoreApplication* qtApp = new QCoreApplication(_argc, &_argv.front()); |
| 498 | (void)qtApp; |
| 499 | |
| 500 | |
| 501 | if (enableBreakpad) { |
| 502 | //This will throw an exception if it fails to start the crash generation server |
| 503 | initCrashGenerationServer(); |
| 504 | assert(_crashServer); |
| 505 | } |
| 506 | |
| 507 | /* |
| 508 | At this point the crash generation server is created |
| 509 | qApp has been defined so far |
| 510 | */ |
| 511 | assert(qApp); |
| 512 | |
| 513 | QString crashReporterBinaryFilePath = qApp->applicationFilePath(); |
| 514 | QString natronBinaryPath = qApp->applicationDirPath(); |
| 515 | natronBinaryPath = getNatronBinaryFilePathFromCrashReporterDirPath(natronBinaryPath); |
| 516 | |
| 517 | if ( !QFile::exists(natronBinaryPath) ) { |
| 518 | _initErr = true; |
| 519 | std::stringstream ss; |
| 520 | ss << natronBinaryPath.toStdString() << ": no such file or directory."; |
| 521 | throw std::runtime_error( ss.str() ); |
| 522 | |
| 523 | return; |
| 524 | } |
| 525 | |
| 526 | #ifndef NATRON_CRASH_REPORTER_USE_FORK |
| 527 | |
| 528 | _natronProcess = new QProcess(); |
| 529 | QObject::connect( _natronProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(onNatronProcessStdOutWrittenTo()) ); |
| 530 | QObject::connect( _natronProcess, SIGNAL(readyReadStandardError()), this, SLOT(onNatronProcessStdErrWrittenTo()) ); |
| 531 | QObject::connect( _natronProcess, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(onSpawnedProcessFinished(int,QProcess::ExitStatus)) ); |
| 532 | QObject::connect( _natronProcess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(onSpawnedProcessError(QProcess::ProcessError)) ); |
nothing calls this directly
no test coverage detected