From ac6fae0f47d918541bd0cef34798602b4a485787 Mon Sep 17 00:00:00 2001 From: amass Date: Mon, 6 Jan 2025 00:01:08 +0800 Subject: [PATCH] add wt app quit. --- WebApplication/Application.cpp | 6 +++++- WebApplication/Application.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/WebApplication/Application.cpp b/WebApplication/Application.cpp index fbb5a0a..37a3e71 100644 --- a/WebApplication/Application.cpp +++ b/WebApplication/Application.cpp @@ -26,7 +26,7 @@ namespace WebToolkit { Application::Application(const Wt::WEnvironment &env, bool embedded) - : Wt::WApplication(env), m_startup(this, "startup"), m_logout(this, "logout") { + : Wt::WApplication(env), m_startup(this, "startup"), m_quit(this, "quit"), m_logout(this, "logout") { messageResourceBundle().use(appRoot() + "wt"); messageResourceBundle().use(appRoot() + "auth_strings"); messageResourceBundle().use(appRoot() + "auth_css_theme"); @@ -96,6 +96,10 @@ Application::Application(const Wt::WEnvironment &env, bool embedded) dynamic_cast(app)->handlePathChange(path); } }); + m_quit.connect(this, []() { + LOG(info) << "wtapp quit."; + Wt::WApplication::instance()->quit(); + }); internalPathChanged().connect(this, &Application::handlePathChange); doJavaScript(m_startup.createCall({})); } diff --git a/WebApplication/Application.h b/WebApplication/Application.h index 48f0684..faa4161 100644 --- a/WebApplication/Application.h +++ b/WebApplication/Application.h @@ -37,6 +37,7 @@ protected: private: std::unique_ptr m_session; Wt::JSignal<> m_startup; + Wt::JSignal<> m_quit; Wt::WContainerWidget *m_root = nullptr; NavigationBar *m_navigationBar = nullptr;