]> git.sesse.net Git - nageru/commitdiff
Give a warning before quitting if there are clients connected.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 8 Nov 2017 21:30:03 +0000 (22:30 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 8 Nov 2017 21:30:11 +0000 (22:30 +0100)
httpd.h
mainwindow.cpp
mixer.h

diff --git a/httpd.h b/httpd.h
index 6e37c5226206b3cd8f5cd5b3dcc8ea9b8b0bcecd..630b0c38bfefb53205050e4eb9563e06455ba69d 100644 (file)
--- a/httpd.h
+++ b/httpd.h
@@ -28,6 +28,9 @@ public:
 
        void start(int port);
        void add_data(const char *buf, size_t size, bool keyframe);
+       int64_t get_num_connected_clients() const {
+               return metric_num_connected_clients.load();
+       }
 
 private:
        static int answer_to_connection_thunk(void *cls, MHD_Connection *connection,
index d46c87c38e7766b667230057482814f8879646ca..d3d298100dd5c9f492dc4c4edacbab0d62581df5 100644 (file)
@@ -1330,6 +1330,16 @@ bool MainWindow::eventFilter(QObject *watched, QEvent *event)
 
 void MainWindow::closeEvent(QCloseEvent *event)
 {
+       if (global_mixer->get_num_connected_clients() > 0) {
+               QMessageBox::StandardButton reply =
+                       QMessageBox::question(this, "Nageru", "There are clients connected. Do you really want to quit?",
+                               QMessageBox::Yes | QMessageBox::No);
+               if (reply != QMessageBox::Yes) {
+                       event->ignore();
+                       return;
+               }
+       }
+
        analyzer->hide();
        event->accept();
 }
diff --git a/mixer.h b/mixer.h
index ff501b17635cd8830ba36e084754577cd75902b5..89676bddf86c9299826651dc68f5a7c887db906a 100644 (file)
--- a/mixer.h
+++ b/mixer.h
@@ -399,6 +399,10 @@ public:
                display_timecode_on_stdout = enable;
        }
 
+       int64_t get_num_connected_clients() const {
+               return httpd.get_num_connected_clients();
+       }
+
 private:
        struct CaptureCard;