diff --git a/src/libs/vmisc/crashhandler/crashhandler.cpp b/src/libs/vmisc/crashhandler/crashhandler.cpp index c7f549f4c..43acc65e7 100644 --- a/src/libs/vmisc/crashhandler/crashhandler.cpp +++ b/src/libs/vmisc/crashhandler/crashhandler.cpp @@ -43,6 +43,9 @@ #define MIN(x, y) (((x) < (y)) ? (x) : (y)) // NOLINT #endif +#include +#include + #include #include #include @@ -58,7 +61,6 @@ #include -using namespace base; using namespace crashpad; namespace @@ -168,7 +170,7 @@ auto InitializeCrashpad(const QString &appName) -> bool #endif // Helper class for cross-platform file systems - VCrashPaths crashpadPaths(exeDir); + VCrashPaths const crashpadPaths(exeDir); auto MakeDir = [](const QString &path) { @@ -182,7 +184,7 @@ auto InitializeCrashpad(const QString &appName) -> bool // Directory where reports will be saved. Important! Must be writable or crashpad_handler will crash. QString const reportsPath = VCrashPaths::GetReportsPath(); MakeDir(reportsPath); - FilePath const reportsDir(VCrashPaths::GetPlatformString(reportsPath)); + base::FilePath const reportsDir(VCrashPaths::GetPlatformString(reportsPath)); // Initialize crashpad database std::unique_ptr database = CrashReportDatabase::Initialize(reportsDir); @@ -200,20 +202,20 @@ auto InitializeCrashpad(const QString &appName) -> bool settings->SetUploadsEnabled(true); // Attachments to be uploaded alongside the crash - default bundle size limit is 20MB - std::vector attachments; - FilePath const attachment(VCrashPaths::GetPlatformString(VCrashPaths::GetAttachmentPath(appName))); + std::vector attachments; + base::FilePath const attachment(VCrashPaths::GetPlatformString(VCrashPaths::GetAttachmentPath(appName))); #if defined(Q_OS_WINDOWS) || defined(Q_OS_LINUX) // Crashpad hasn't implemented attachments on OS X yet attachments.push_back(attachment); #endif // Ensure that crashpad_handler is shipped with your application - FilePath const handler(VCrashPaths::GetPlatformString(crashpadPaths.GetHandlerPath())); + base::FilePath const handler(VCrashPaths::GetPlatformString(crashpadPaths.GetHandlerPath())); // Directory where metrics will be saved. Important! Must be writable or crashpad_handler will crash. QString const metricsPath = VCrashPaths::GetMetricsPath(); MakeDir(metricsPath); - FilePath const metricsDir(VCrashPaths::GetPlatformString(metricsPath)); + base::FilePath const metricsDir(VCrashPaths::GetPlatformString(metricsPath)); QString const dbName = QStringLiteral("valentina"); // Configure url with your BugSplat database @@ -221,7 +223,7 @@ auto InitializeCrashpad(const QString &appName) -> bool // Metadata that will be posted to BugSplat QMap annotations; - annotations["format"] = "minidump"; // Required: Crashpad setting to save crash as a minidump + annotations["format"] = "minidump"; // Required: Crashpad setting to save crash as a annotations["database"] = dbName.toStdString(); // Required: BugSplat database annotations["product"] = appName.toStdString(); // Required: BugSplat appName annotations["version"] = AppCrashVersion().toStdString(); // Required: BugSplat appVersion @@ -245,7 +247,7 @@ auto InitializeCrashpad(const QString &appName) -> bool arguments.emplace_back("--no-rate-limit"); // Start crash handler - auto *client = new CrashpadClient(); - return client->StartHandler(handler, reportsDir, metricsDir, url.toStdString(), "", annotations.toStdMap(), - arguments, true, true, attachments); + CrashpadClient client; + return client.StartHandler(handler, reportsDir, metricsDir, url.toStdString(), "", annotations.toStdMap(), + arguments, true, true, attachments); } diff --git a/src/libs/vmisc/crashhandler/vcrashpaths.cpp b/src/libs/vmisc/crashhandler/vcrashpaths.cpp index e181d8d8a..54d65935b 100644 --- a/src/libs/vmisc/crashhandler/vcrashpaths.cpp +++ b/src/libs/vmisc/crashhandler/vcrashpaths.cpp @@ -49,7 +49,7 @@ auto VCrashPaths::GetAttachmentPath(const QString &appName) -> QString } //--------------------------------------------------------------------------------------------------------------------- -auto VCrashPaths::GetHandlerPath() -> QString +auto VCrashPaths::GetHandlerPath() const -> QString { #if defined(Q_OS_WINDOWS) const QString handler = QStringLiteral("crashpad_handler.exe"); @@ -76,16 +76,14 @@ auto VCrashPaths::GetMetricsPath() -> QString } //--------------------------------------------------------------------------------------------------------------------- + +auto VCrashPaths::GetPlatformString(const QString &string) -> base::FilePath::StringType +{ #if defined(Q_OS_UNIX) -auto VCrashPaths::GetPlatformString(const QString &string) -> std::string -{ return string.toStdString(); -} #elif defined(Q_OS_WINDOWS) -auto VCrashPaths::GetPlatformString(const QString &string) -> std::wstring -{ - return string.toStdWString(); -} #else + return string.toStdWString(); #error GetPlatformString not implemented on this platform #endif +} diff --git a/src/libs/vmisc/crashhandler/vcrashpaths.h b/src/libs/vmisc/crashhandler/vcrashpaths.h index f3bcca7a2..bd6e8dd34 100644 --- a/src/libs/vmisc/crashhandler/vcrashpaths.h +++ b/src/libs/vmisc/crashhandler/vcrashpaths.h @@ -30,22 +30,22 @@ #include +#include + class VCrashPaths { public: explicit VCrashPaths(QString exeDir); - auto GetHandlerPath() -> QString; + auto GetHandlerPath() const -> QString; static auto GetAttachmentPath(const QString &appName) -> QString; static auto GetReportsPath() -> QString; static auto GetMetricsPath() -> QString; -#if defined(Q_OS_UNIX) - static auto GetPlatformString(const QString &string) -> std::string; -#elif defined(Q_OS_WINDOWS) - static auto GetPlatformString(const QString &string) -> std::wstring; -#else +#if defined(Q_OS_UNIX) || defined(Q_OS_WINDOWS) + static auto GetPlatformString(const QString &string) -> base::FilePath::StringType; +#elif #error GetPlatformString not implemented on this platform #endif