diff options
author | Tim Jenssen <tim.jenssen@qt.io> | 2023-03-03 18:13:30 +0100 |
---|---|---|
committer | Tim Jenssen <tim.jenssen@qt.io> | 2023-03-06 04:46:29 +0000 |
commit | 75d7f1de6c1789bf7a3c4c2a5b88fdcbabebb7cb (patch) | |
tree | 1058c7ef52c6e9ba6a2bc3172a85089ce4945423 | |
parent | 62334c2b7a0f128aa5da7985ddbddcad6de94719 (diff) |
crashpad: change chrashpad dumps location to user directory on macOS
This is necessary to not pollute the signed and notarized .app
bundle.
Task-number: QDS-9113
Change-Id: I74e0bced5679faac94b27d2a31ea10a7949fb21f
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
(cherry picked from commit b619f24396ab5d446f39d2d53904829254c19a80)
-rw-r--r-- | src/app/main.cpp | 15 | ||||
-rw-r--r-- | src/plugins/coreplugin/icore.cpp | 2 | ||||
-rw-r--r-- | src/tools/qml2puppet/qml2puppet/configcrashpad.h | 16 | ||||
-rw-r--r-- | src/tools/qml2puppet/qml2puppet/qmlpuppet.cpp | 22 |
4 files changed, 48 insertions, 7 deletions
diff --git a/src/app/main.cpp b/src/app/main.cpp index 5665dfa312..025d219d2e 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -425,13 +425,26 @@ QStringList lastSessionArgument() return hasProjectExplorer ? QStringList({"-lastsession"}) : QStringList(); } +// should be in sync with src/plugins/coreplugin/icore.cpp -> FilePath ICore::crashReportsPath() +// and src\tools\qml2puppet\qml2puppet\qmlpuppet.cpp -> QString crashReportsPath() +QString crashReportsPath() +{ + std::unique_ptr<QSettings> settings(createUserSettings()); + QFileInfo(settings->fileName()).path() + "/crashpad_reports"; + if (Utils::HostOsInfo::isMacHost()) + return QFileInfo(createUserSettings()->fileName()).path() + "/crashpad_reports"; + else + return QCoreApplication::applicationDirPath() + + '/' + RELATIVE_LIBEXEC_PATH + "crashpad_reports"; +} + #ifdef ENABLE_CRASHPAD bool startCrashpad(const QString &libexecPath, bool crashReportingEnabled) { using namespace crashpad; // Cache directory that will store crashpad information and minidumps - QString databasePath = QDir::cleanPath(libexecPath + "/crashpad_reports"); + QString databasePath = QDir::cleanPath(crashReportsPath()); QString handlerPath = QDir::cleanPath(libexecPath + "/crashpad_handler"); #ifdef Q_OS_WIN handlerPath += ".exe"; diff --git a/src/plugins/coreplugin/icore.cpp b/src/plugins/coreplugin/icore.cpp index 6d8a35b62c..2fed259314 100644 --- a/src/plugins/coreplugin/icore.cpp +++ b/src/plugins/coreplugin/icore.cpp @@ -511,7 +511,7 @@ FilePath ICore::libexecPath(const QString &rel) FilePath ICore::crashReportsPath() { if (Utils::HostOsInfo::isMacHost()) - return libexecPath("crashpad_reports/completed"); + return Core::ICore::userResourcePath("crashpad_reports/completed"); else return libexecPath("crashpad_reports/reports"); } diff --git a/src/tools/qml2puppet/qml2puppet/configcrashpad.h b/src/tools/qml2puppet/qml2puppet/configcrashpad.h index 7b663b8449..d6ecc8af4f 100644 --- a/src/tools/qml2puppet/qml2puppet/configcrashpad.h +++ b/src/tools/qml2puppet/qml2puppet/configcrashpad.h @@ -17,13 +17,21 @@ namespace { #if defined(ENABLE_CRASHPAD) && defined(Q_OS_WIN) - bool startCrashpad() + bool startCrashpad(const QString& libexecPath, const QString& crashReportsPath) { using namespace crashpad; // Cache directory that will store crashpad information and minidumps - base::FilePath database(L"crashpad_reports"); - base::FilePath handler(L"crashpad_handler.exe"); + QString databasePath = QDir::cleanPath(crashReportsPath); + QString handlerPath = QDir::cleanPath(libexecPath + "/crashpad_handler"); + #ifdef Q_OS_WIN + handlerPath += ".exe"; + base::FilePath database(databasePath.toStdWString()); + base::FilePath handler(handlerPath.toStdWString()); + #elif defined(Q_OS_MACOS) || defined(Q_OS_LINUX) + base::FilePath database(databasePath.toStdString()); + base::FilePath handler(handlerPath.toStdString()); + #endif // URL used to submit minidumps to std::string url(CRASHPAD_BACKEND_URL); @@ -58,7 +66,7 @@ namespace { QtSystemExceptionHandler systemExceptionHandler(libexecPath); #endif //#ifdef ENABLE_QT_BREAKPAD #else //#if defined(ENABLE_CRASHPAD) && defined(Q_OS_WIN) - bool startCrashpad() + bool startCrashpad(const QString&, const QString&) { return false; } diff --git a/src/tools/qml2puppet/qml2puppet/qmlpuppet.cpp b/src/tools/qml2puppet/qml2puppet/qmlpuppet.cpp index 8a3822a86e..f2d9ff405f 100644 --- a/src/tools/qml2puppet/qml2puppet/qmlpuppet.cpp +++ b/src/tools/qml2puppet/qml2puppet/qmlpuppet.cpp @@ -16,6 +16,7 @@ #include <QFileInfo> #include <QQmlComponent> #include <QQmlEngine> +#include <QSettings> #if defined(Q_OS_WIN) && defined(QT_NO_DEBUG) #include <Windows.h> @@ -75,6 +76,24 @@ void QmlPuppet::populateParser() {"import3dAsset", "Import 3d asset.", "sourceAsset, outDir, importOptJson"}}); } +// should be in sync with coreplugin/icore.cpp -> FilePath ICore::crashReportsPath() +// and src\app\main.cpp +QString crashReportsPath() +{ + QSettings settings( + QSettings::IniFormat, + QSettings::UserScope, + QLatin1String(Core::Constants::IDE_SETTINGSVARIANT_STR), + QLatin1String(Core::Constants::IDE_CASED_ID)); + +#if defined(Q_OS_MACOS) + return QFileInfo(settings.fileName()).path() + "/crashpad_reports"; +#else + return QCoreApplication::applicationDirPath() + + '/' + RELATIVE_LIBEXEC_PATH + "crashpad_reports"; +#endif +} + void QmlPuppet::initQmlRunner() { if (m_coreApp->arguments().count() < 2 @@ -117,7 +136,8 @@ void QmlPuppet::initQmlRunner() Import3D::import3D(sourceAsset, outDir, options); } - startCrashpad(); + startCrashpad(QCoreApplication::applicationDirPath() + + '/' + RELATIVE_LIBEXEC_PATH, crashReportsPath()); new QmlDesigner::Qt5NodeInstanceClientProxy(m_coreApp.get()); |