[4/4] kernel-shark: Cleanup in KsCaptureDialog
diff mbox series

Message ID 20190920104831.23475-5-y.karadz@gmail.com
State Accepted
Headers show
Series
  • Fixes needed for KS 1.1
Related show

Commit Message

Yordan Karadzhov (VMware) Sept. 20, 2019, 10:48 a.m. UTC
My original intend was to fix a Doxygen warning complaining about a data
member of a class not being documented. However, when I tried to write
explanation for this data member (KsCaptureMonitor::_captureStatus),
I realized that it is completely useless and that it actually violates
the encapsulation principle, since it holds the return status of the
capture process, but the capture process itself is owned by another
class (KsCaptureDialog).

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 kernel-shark/src/KsCaptureDialog.cpp | 21 +++++++++++----------
 kernel-shark/src/KsCaptureDialog.hpp |  2 --
 2 files changed, 11 insertions(+), 12 deletions(-)

Patch
diff mbox series

diff --git a/kernel-shark/src/KsCaptureDialog.cpp b/kernel-shark/src/KsCaptureDialog.cpp
index fff42aa..ad05917 100644
--- a/kernel-shark/src/KsCaptureDialog.cpp
+++ b/kernel-shark/src/KsCaptureDialog.cpp
@@ -385,7 +385,6 @@  KsCaptureMonitor::KsCaptureMonitor(QWidget *parent)
 : QWidget(parent),
   _mergedChannels(false),
   _argsModified(false),
-  _captureStatus(false),
   _panel(this),
   _name("Output display", this),
   _space("max size ", this),
@@ -523,9 +522,6 @@  void KsCaptureMonitor::_captureFinished(int exit, QProcess::ExitStatus status)
 		_consolOutput.appendPlainText(errMessage);
 
 		QCoreApplication::processEvents();
-		_captureStatus = false;
-	} else {
-		_captureStatus = true;
 	}
 }
 
@@ -585,6 +581,17 @@  void KsCaptureDialog::_capture()
 	_captureProc.start();
 	_captureProc.waitForFinished();
 
+	/* Reset the _argsModified flag. */
+	_captureMon._argsModified = false;
+
+	if (_captureProc.exitCode() != 0 ||
+	    _captureProc.exitStatus() != QProcess::NormalExit)
+		return;
+
+	/*
+	 * Capture finished successfully. Open the produced tracing data file
+	 * in KernelShark.
+	 */
 	argc = argv.count();
 	for (int i = 0; i < argc; ++i) {
 		if (argv[i] == "-o") {
@@ -592,9 +599,6 @@  void KsCaptureDialog::_capture()
 			break;
 		}
 	}
-
-	/* Reset the _argsModified flag. */
-	_captureMon._argsModified = false;
 }
 
 void KsCaptureDialog::_setChannelMode(int state)
@@ -610,9 +614,6 @@  void KsCaptureDialog::_sendOpenReq(const QString &fileName)
 {
 	QLocalSocket *socket;
 
-	if (!_captureMon._captureStatus)
-		return;
-
 	socket = new QLocalSocket(this);
 	socket->connectToServer("KSCapture", QIODevice::WriteOnly);
 	if (socket->waitForConnected()) {
diff --git a/kernel-shark/src/KsCaptureDialog.hpp b/kernel-shark/src/KsCaptureDialog.hpp
index 612080c..3fd3d8d 100644
--- a/kernel-shark/src/KsCaptureDialog.hpp
+++ b/kernel-shark/src/KsCaptureDialog.hpp
@@ -141,8 +141,6 @@  public:
 	 */
 	bool		_argsModified;
 
-	bool		_captureStatus;
-
 private:
 	QVBoxLayout	_layout;