diff --git a/UI/obs-app.cpp b/UI/obs-app.cpp index d413a5685..887d6bb63 100644 --- a/UI/obs-app.cpp +++ b/UI/obs-app.cpp @@ -1428,6 +1428,9 @@ OBSApp::OBSApp(int &argc, char **argv, profiler_name_store_t *store) snInt = new QSocketNotifier(sigintFd[1], QSocketNotifier::Read, this); connect(snInt, &QSocketNotifier::activated, this, &OBSApp::ProcessSigInt); +#else + connect(qApp, &QGuiApplication::commitDataRequest, this, + &OBSApp::commitData); #endif sleepInhibitor = os_inhibit_sleep_create("OBS Video/audio"); @@ -3270,6 +3273,16 @@ void OBSApp::ProcessSigInt(void) #endif } +#ifdef _WIN32 +void OBSApp::commitData(QSessionManager &manager) +{ + if (auto main = App()->GetMainWindow()) { + QMetaObject::invokeMethod(main, "close", Qt::QueuedConnection); + manager.cancel(); + } +} +#endif + int main(int argc, char *argv[]) { #ifndef _WIN32 diff --git a/UI/obs-app.hpp b/UI/obs-app.hpp index 65a45e939..94c3f349b 100644 --- a/UI/obs-app.hpp +++ b/UI/obs-app.hpp @@ -22,6 +22,8 @@ #include #ifndef _WIN32 #include +#else +#include #endif #include #include @@ -132,6 +134,9 @@ private: #ifndef _WIN32 static int sigintFd[2]; QSocketNotifier *snInt = nullptr; +#else +private slots: + void commitData(QSessionManager &manager); #endif public: