Explorar o código

UI: cancel session end request on commitDataRequest() signal

derrod hai 1 ano
pai
achega
c523f11bcd
Modificáronse 2 ficheiros con 18 adicións e 0 borrados
  1. 13 0
      UI/obs-app.cpp
  2. 5 0
      UI/obs-app.hpp

+ 13 - 0
UI/obs-app.cpp

@@ -1414,6 +1414,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");
@@ -3256,6 +3259,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

+ 5 - 0
UI/obs-app.hpp

@@ -22,6 +22,8 @@
 #include <QPointer>
 #ifndef _WIN32
 #include <QSocketNotifier>
+#else
+#include <QSessionManager>
 #endif
 #include <obs.hpp>
 #include <util/lexer.h>
@@ -132,6 +134,9 @@ private:
 #ifndef _WIN32
 	static int sigintFd[2];
 	QSocketNotifier *snInt = nullptr;
+#else
+private slots:
+	void commitData(QSessionManager &manager);
 #endif
 
 public: