diff mbox series

[04/17] kernel-shark qt: No error when Record authentication dialog is closed

Message ID 20181128151530.21965-5-ykaradzhov@vmware.com (mailing list archive)
State Accepted
Commit d8d1496539375d8b9feacf6d4ea575316ab3126c
Headers show
Series More modifications and bug fixes toward KS 1.0 | expand

Commit Message

Yordan Karadzhov Nov. 28, 2018, 3:16 p.m. UTC
No error message must be shown in the case when the user dismissed
the authentication dialog (clicked Cancel).

Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
---
 kernel-shark-qt/src/KsMainWindow.cpp | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/kernel-shark-qt/src/KsMainWindow.cpp b/kernel-shark-qt/src/KsMainWindow.cpp
index ffb10d4..8e8484f 100644
--- a/kernel-shark-qt/src/KsMainWindow.cpp
+++ b/kernel-shark-qt/src/KsMainWindow.cpp
@@ -959,13 +959,28 @@  void KsMainWindow::_captureStarted()
 	_captureLocalServer.listen("KSCapture");
 }
 
-void KsMainWindow::_captureFinished(int exit, QProcess::ExitStatus st)
+/**
+ * If the authorization could not be obtained because the user dismissed
+ * the authentication dialog (clicked Cancel), pkexec exits with a return
+ * value of 126.
+ */
+#define PKEXEC_DISMISS_RET	126
+
+void KsMainWindow::_captureFinished(int ret, QProcess::ExitStatus st)
 {
 	QProcess *capture = (QProcess *)sender();
 
 	_captureLocalServer.close();
 
-	if (exit != 0 || st != QProcess::NormalExit) {
+	if (ret == PKEXEC_DISMISS_RET) {
+		/*
+		 * Authorization could not be obtained because the user
+		 * dismissed the authentication dialog.
+		 */
+		return;
+	}
+
+	if (ret != 0 || st != QProcess::NormalExit) {
 		QString message = "Capture process failed:<br>";
 
 		message += capture->errorString();