chatgui: rework shutdown — main thread owns cleanup, remove glШбаls
Changes: - UtunNode::requestStop() — async stop from any thread (m_stop+wakeup) - UtunNode::finalize() — cleanup in main thread (etcp_router, chat_sync, chat_core, utun_instance, uasync) - UtunNode::stop() — requestStop + join + finalize (for tray Quit path) - Worker runLoop: only exits poll loop on m_stop, then emits stopped — no cleanup - stopped() handler: calls finalize() in main thread, then qApp->quit() - Tray Quit: calls requestStop(), stopped handler does finalize+quit - Ctrl-C (Windows): SetConsoleCtrlHandler calls requestStop() via g_ctrl_node - Ctrl-C (Linux): signal_handler calls requestStop() via g_currentNode - Removed: g_shutdown, g_signal_ua, utun_node_signal_shutdown globals
This commit is contained in:
1 parent
4c623e25ce
commit
fbaf58530f
5 files changed
+41
-32
No files matched your search
@@ -120,10 +120,11 @@ void MainWindow::setupNode() {
|
||||
connect(m_node, &UtunNode::started, this, []() {
|
||||
qDebug("UtunNode started");
|
||||
});
|
||||
connect(m_node, &UtunNode::stopped, this, []() {
|
||||
connect(m_node, &UtunNode::stopped, this, [this]() {
|
||||
qDebug("UtunNode stopped");
|
||||
if (m_node) m_node->finalize();
|
||||
qApp->quit();
|
||||
});
|
||||
connect(m_node, &UtunNode::stopped, qApp, &QApplication::quit);
|
||||
|
||||
if (!m_cfgDebugFile.isEmpty())
|
||||
m_node->setDebugFile(m_cfgDebugFile);
|
||||
@@ -255,7 +256,9 @@ void MainWindow::setupTray() {
|
||||
});
|
||||
|
||||
QAction *quitAction = m_trayMenu->addAction("Quit");
|
||||
connect(quitAction, &QAction::triggered, qApp, &QApplication::quit);
|
||||
connect(quitAction, &QAction::triggered, this, [this]() {
|
||||
if (m_node) m_node->requestStop();
|
||||
});
|
||||
|
||||
m_trayIcon->setContextMenu(m_trayMenu);
|
||||
|
||||
|
||||
Reference in new issue
Block a user