From: Steinar H. Gunderson Date: Wed, 8 Nov 2017 21:30:03 +0000 (+0100) Subject: Give a warning before quitting if there are clients connected. X-Git-Tag: 1.6.4~9 X-Git-Url: https://git.sesse.net/?p=nageru;a=commitdiff_plain;h=70e175fb0deb01e4664213686491c49bff85faf6 Give a warning before quitting if there are clients connected. --- diff --git a/httpd.h b/httpd.h index 6e37c52..630b0c3 100644 --- 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, diff --git a/mainwindow.cpp b/mainwindow.cpp index d46c87c..d3d2981 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -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 ff501b1..89676bd 100644 --- 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;