diff options
| author | 2023-06-27 23:34:16 +0200 | |
|---|---|---|
| committer | 2023-06-27 18:12:26 -0400 | |
| commit | 32475efbc4326a3e7a97883f39b21b91fd14af60 (patch) | |
| tree | 638bd64bae8d976e5406a0e742869a469f60495a /src/common/settings.cpp | |
| parent | Merge pull request #10931 from german77/clang (diff) | |
| download | yuzu-32475efbc4326a3e7a97883f39b21b91fd14af60.tar.gz yuzu-32475efbc4326a3e7a97883f39b21b91fd14af60.tar.xz yuzu-32475efbc4326a3e7a97883f39b21b91fd14af60.zip | |
settings: Catch runtime_error, fallback time zone
Windows will let you select time zones that will fail in their
own C++ implementation library. Evidently from the stack trace, we get a
runtime error to work with, so catch it and use the fallback.
Diffstat (limited to 'src/common/settings.cpp')
| -rw-r--r-- | src/common/settings.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 66dffc9bf..a1df69140 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include <exception> | ||
| 5 | #include <stdexcept> | ||
| 4 | #if __cpp_lib_chrono >= 201907L | 6 | #if __cpp_lib_chrono >= 201907L |
| 5 | #include <chrono> | 7 | #include <chrono> |
| 6 | #endif | 8 | #endif |
| @@ -25,9 +27,19 @@ std::string GetTimeZoneString() { | |||
| 25 | if (time_zone_index == 0) { // Auto | 27 | if (time_zone_index == 0) { // Auto |
| 26 | #if __cpp_lib_chrono >= 201907L | 28 | #if __cpp_lib_chrono >= 201907L |
| 27 | const struct std::chrono::tzdb& time_zone_data = std::chrono::get_tzdb(); | 29 | const struct std::chrono::tzdb& time_zone_data = std::chrono::get_tzdb(); |
| 28 | const std::chrono::time_zone* current_zone = time_zone_data.current_zone(); | 30 | try { |
| 29 | std::string_view current_zone_name = current_zone->name(); | 31 | const std::chrono::time_zone* current_zone = time_zone_data.current_zone(); |
| 30 | location_name = current_zone_name; | 32 | std::string_view current_zone_name = current_zone->name(); |
| 33 | location_name = current_zone_name; | ||
| 34 | } catch (std::runtime_error& runtime_error) { | ||
| 35 | // VCRUNTIME will throw a runtime_error if the operating system's selected time zone | ||
| 36 | // cannot be found | ||
| 37 | location_name = Common::TimeZone::FindSystemTimeZone(); | ||
| 38 | LOG_WARNING(Common, | ||
| 39 | "Error occurred when trying to determine system time zone:\n{}\nFalling " | ||
| 40 | "back to hour offset \"{}\"", | ||
| 41 | runtime_error.what(), location_name); | ||
| 42 | } | ||
| 31 | #else | 43 | #else |
| 32 | location_name = Common::TimeZone::FindSystemTimeZone(); | 44 | location_name = Common::TimeZone::FindSystemTimeZone(); |
| 33 | #endif | 45 | #endif |