diff mbox series

[7/8] kernel-shark: Disconnect "capture errors" before closing KernelShark GUI

Message ID 20190709155650.2345-8-y.karadz@gmail.com (mailing list archive)
State Accepted
Headers show
Series Fixes needed befor KS 1.0 | expand

Commit Message

Yordan Karadzhov July 9, 2019, 3:56 p.m. UTC
This is done because we do not want to show error messages if the Capture
dialog is not closed.

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 kernel-shark/src/KsMainWindow.cpp | 15 +++++++++++++--
 kernel-shark/src/KsMainWindow.hpp |  2 ++
 2 files changed, 15 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/kernel-shark/src/KsMainWindow.cpp b/kernel-shark/src/KsMainWindow.cpp
index 3f238db..55518a3 100644
--- a/kernel-shark/src/KsMainWindow.cpp
+++ b/kernel-shark/src/KsMainWindow.cpp
@@ -155,6 +155,16 @@  KsMainWindow::~KsMainWindow()
 
 	_data.clear();
 
+	/*
+	 * Do not show error messages if the "capture" process is still
+	 * running (Capture dialog is not closed).
+	 */
+	if (_capture.state() != QProcess::NotRunning) {
+		disconnect(_captureErrorConnection);
+		_capture.close();
+		_capture.waitForFinished();
+	}
+
 	if (kshark_instance(&kshark_ctx))
 		kshark_free(kshark_ctx);
 }
@@ -1129,8 +1139,9 @@  void KsMainWindow::_initCapture()
 	connect(&_capture,	SIGNAL(finished(int, QProcess::ExitStatus)),
 		this,		SLOT(_captureFinished(int, QProcess::ExitStatus)));
 
-	connect(&_capture,	&QProcess::errorOccurred,
-		this,		&KsMainWindow::_captureError);
+	_captureErrorConnection =
+		connect(&_capture,	&QProcess::errorOccurred,
+			this,		&KsMainWindow::_captureError);
 
 	connect(&_captureLocalServer,	&QLocalServer::newConnection,
 		this,			&KsMainWindow::_readSocket);
diff --git a/kernel-shark/src/KsMainWindow.hpp b/kernel-shark/src/KsMainWindow.hpp
index 22700d9..62e66a0 100644
--- a/kernel-shark/src/KsMainWindow.hpp
+++ b/kernel-shark/src/KsMainWindow.hpp
@@ -159,6 +159,8 @@  private:
 
 	QSettings	_settings;
 
+	QMetaObject::Connection		_captureErrorConnection;
+
 	void _open();
 
 	void _restoreSession();