From a90a5cba08fdf6c0ceb95101c275108a152a3aed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:35:37 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- toolkit/crashreporter/nsExceptionHandler.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'toolkit/crashreporter/nsExceptionHandler.cpp') diff --git a/toolkit/crashreporter/nsExceptionHandler.cpp b/toolkit/crashreporter/nsExceptionHandler.cpp index 868005a5c7..0f8a58aa88 100644 --- a/toolkit/crashreporter/nsExceptionHandler.cpp +++ b/toolkit/crashreporter/nsExceptionHandler.cpp @@ -96,6 +96,9 @@ using mozilla::InjectCrashRunnable; #endif +#ifdef XP_WIN +# include +#endif #include #include @@ -2768,12 +2771,23 @@ static nsresult PrefSubmitReports(bool* aSubmitReports, bool writePref) { * toolkit/crashreporter/client/app/src/{logic,settings}.rs */ nsCOMPtr reporterSettings; - rv = NS_GetSpecialDirectory("UAppData", getter_AddRefs(reporterSettings)); + rv = NS_GetSpecialDirectory(XRE_USER_APP_DATA_DIR, + getter_AddRefs(reporterSettings)); NS_ENSURE_SUCCESS(rv, rv); reporterSettings->AppendNative("Crash Reports"_ns); reporterSettings->AppendNative("crashreporter_settings.json"_ns); + // On e.g. Linux, std::filesystem requires sometimes linking libstdc++fs, + // and we don't do that yet, so limit the use of std::filesystem::path where + // it's really needed, which is Windows, because implicit conversions from + // wstring in fstream constructors are not supported as of + // https://cplusplus.github.io/LWG/issue3430. +# ifdef XP_WIN + std::optional file_path = + CreatePathFromFile(reporterSettings); +# else std::optional file_path = CreatePathFromFile(reporterSettings); +# endif if (!file_path) { return NS_ERROR_FAILURE; @@ -2900,7 +2914,7 @@ void UpdateCrashEventsDir() { return; } - rv = NS_GetSpecialDirectory("UAppData", getter_AddRefs(eventsDir)); + rv = NS_GetSpecialDirectory(XRE_USER_APP_DATA_DIR, getter_AddRefs(eventsDir)); if (NS_SUCCEEDED(rv)) { SetUserAppDataDirectory(eventsDir); return; @@ -2962,7 +2976,8 @@ static void FindPendingDir() { return; } nsCOMPtr pendingDir; - nsresult rv = NS_GetSpecialDirectory("UAppData", getter_AddRefs(pendingDir)); + nsresult rv = + NS_GetSpecialDirectory(XRE_USER_APP_DATA_DIR, getter_AddRefs(pendingDir)); if (NS_FAILED(rv)) { NS_WARNING( "Couldn't get the user appdata directory, crash dumps will go in an " -- cgit v1.2.3