From 74c6b0d10263497d886e1283929ef73d6aaea188 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Fri, 24 Jul 2026 14:34:00 +0300 Subject: [PATCH] =?UTF-8?q?chatgui:=20add=20shutdown=20diagnostics=20?= =?UTF-8?q?=E2=80=94=20~DbManager,=20~SoundManager,=20g=5Fshutdown=5Fsenti?= =?UTF-8?q?nel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three diagnostic points covering the gap between ~MainWindow done and CRT exit: - DbManager: destroyed — confirms local dtors started after ~MainWindow - SoundManager: static destructor entered — confirms static destruction phase - main: static destructors done (g_shutdown_sentinel dtor) — confirms ALL statics done If process hangs, we know exactly which phase failed. --- tools/chatgui/db/db_manager.cpp | 2 ++ tools/chatgui/src/main.cpp | 9 ++++++++- tools/chatgui/src/sound_manager.cpp | 5 ++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/chatgui/db/db_manager.cpp b/tools/chatgui/db/db_manager.cpp index 0c355327..942e651b 100644 --- a/tools/chatgui/db/db_manager.cpp +++ b/tools/chatgui/db/db_manager.cpp @@ -1,5 +1,6 @@ #include "db_manager.h" #include "../src/debug_ui.h" +#include "../../lib/debug_config.h" #include #include #include @@ -78,6 +79,7 @@ DbManager::~DbManager() { for (auto it = m_cursors.begin(); it != m_cursors.end(); ++it) sqlite3_finalize(it.value()); m_cursors.clear(); + DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "DbManager: destroyed"); } sqlite3_stmt* DbManager::prepareOrNull(const char* sql) const { diff --git a/tools/chatgui/src/main.cpp b/tools/chatgui/src/main.cpp index 3674860c..71c9825b 100644 --- a/tools/chatgui/src/main.cpp +++ b/tools/chatgui/src/main.cpp @@ -10,6 +10,7 @@ #include "../db/db_manager.h" #include "../transport/node_config.h" #include "../transport/utun_node.h" +#include "../../lib/debug_config.h" #ifdef _WIN32 static UtunNode* g_ctrl_node = nullptr; @@ -23,6 +24,12 @@ static BOOL WINAPI console_ctrl_handler(DWORD dwCtrlType) { } #endif +static struct ShutdownSentinel { + ~ShutdownSentinel() { + DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "main: static destructors done"); + } +} g_shutdown_sentinel; + int main(int argc, char *argv[]) { QApplication app(argc, argv); app.setApplicationName("Chat"); @@ -98,6 +105,6 @@ int main(int argc, char *argv[]) { #endif int ret = app.exec(); - qDebug("main: app.exec() returned %d", ret); + DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "main: app.exec() returned %d", ret); return ret; } diff --git a/tools/chatgui/src/sound_manager.cpp b/tools/chatgui/src/sound_manager.cpp index 46603c69..e391fda1 100644 --- a/tools/chatgui/src/sound_manager.cpp +++ b/tools/chatgui/src/sound_manager.cpp @@ -10,7 +10,10 @@ SoundManager* SoundManager::instance() { return &s; } -SoundManager::~SoundManager() { shutdown(); } +SoundManager::~SoundManager() { + DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "SoundManager: static destructor entered"); + shutdown(); +} bool SoundManager::init() { if (m_initialized) return true;