From 16729c2b6151f256ecb2f0031b5b11e31e749ce0 Mon Sep 17 00:00:00 2001 From: Chris Dolan Date: Tue, 10 Jan 2023 13:27:40 -0700 Subject: [PATCH] Close #19032: Use RAII for crash registration when loading park file (#19100) Co-authored-by: Christopher G. Dolan --- src/openrct2/Context.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index e848ef084f..cb0c71ef0b 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -559,16 +559,19 @@ namespace OpenRCT2 { log_verbose("Context::LoadParkFromFile(%s)", path.c_str()); - // Register the file for crash upload if it asserts while loading. - crash_register_additional_file("load_park", path); - // Deregister park file in case it was processed without hitting an assert. - struct foo + struct CrashAdditionalFileRegistration { - ~foo() + CrashAdditionalFileRegistration(const std::string& path) { + // Register the file for crash upload if it asserts while loading. + crash_register_additional_file("load_park", path); + } + ~CrashAdditionalFileRegistration() + { + // Deregister park file in case it was processed without hitting an assert. crash_unregister_additional_file("load_park"); } - } f; + } crash_additional_file_registration(path); try {