From 4492703f993dec5855cbdeb2a7112ad14611a0d0 Mon Sep 17 00:00:00 2001 From: alef Date: Thu, 6 Feb 2025 22:39:54 +0100 Subject: [PATCH 1/3] Fix #79551 Refactor debug file management by replacing destructor call with explicit deinitialization method --- src/debug.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/debug.cpp b/src/debug.cpp index 94b7f38c3e7b6..61ceedc80df26 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -704,8 +704,8 @@ struct OutputDebugStreamA : public std::ostream { #endif struct DebugFile { - ~DebugFile(); void init( DebugOutput, const cata_path &filename ); + void deinit(); std::ostream &get_file(); static DebugFile &instance() { static DebugFile instance; @@ -720,7 +720,7 @@ struct DebugFile { // DebugFile OStream Wrapper {{{2 // --------------------------------------------------------------------- -DebugFile::~DebugFile() +void DebugFile::deinit() { if( file && file.get() != &std::cerr ) { output_repetitions( *file ); @@ -836,7 +836,7 @@ void setupDebug( DebugOutput output_mode ) void deinitDebug() { - DebugFile::instance().~DebugFile(); + DebugFile::instance().deinit(); } // OStream Operators {{{2 From c68f010358ef1c7ee6bf003708ac2950b5456965 Mon Sep 17 00:00:00 2001 From: alef Date: Fri, 7 Feb 2025 21:08:56 +0100 Subject: [PATCH 2/3] deinit in destructor --- src/debug.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/debug.cpp b/src/debug.cpp index 61ceedc80df26..4f0a99299e068 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -706,6 +706,7 @@ struct OutputDebugStreamA : public std::ostream { struct DebugFile { void init( DebugOutput, const cata_path &filename ); void deinit(); + ~DebugFile() { deinit(); } std::ostream &get_file(); static DebugFile &instance() { static DebugFile instance; From 5bf1c9a6d3d5d1d28b28a4b786e3a2f1347d2586 Mon Sep 17 00:00:00 2001 From: alef Date: Fri, 7 Feb 2025 21:10:27 +0100 Subject: [PATCH 3/3] Update src/debug.cpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/debug.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/debug.cpp b/src/debug.cpp index 4f0a99299e068..c7c2aa881d8ff 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -706,7 +706,9 @@ struct OutputDebugStreamA : public std::ostream { struct DebugFile { void init( DebugOutput, const cata_path &filename ); void deinit(); - ~DebugFile() { deinit(); } + ~DebugFile() { + deinit(); + } std::ostream &get_file(); static DebugFile &instance() { static DebugFile instance;