From 2627d476f4a7d1ca6561abbd4bc9f671fec63523 Mon Sep 17 00:00:00 2001 From: Shubham Jangra Date: Sun, 9 Jun 2019 22:10:15 +0530 Subject: [PATCH] Create a timer to wait for system to free resources Reviewers: stikonas Reviewed By: stikonas Differential Revision: https://phabricator.kde.org/D21696 --- src/util/externalcommand.cpp | 11 +++++++++-- src/util/externalcommand.h | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/util/externalcommand.cpp b/src/util/externalcommand.cpp index 0568bb6..5ed64c1 100644 --- a/src/util/externalcommand.cpp +++ b/src/util/externalcommand.cpp @@ -119,13 +119,12 @@ void ExternalCommand::setup() */ bool ExternalCommand::start(int timeout) { - Q_UNUSED(timeout) - if (command().isEmpty()) return false; if (!QDBusConnection::systemBus().isConnected()) { qWarning() << QDBusConnection::systemBus().lastError().message(); + QTimer::singleShot(timeout, this, &ExternalCommand::quit); return false; } @@ -168,6 +167,8 @@ bool ExternalCommand::start(int timeout) connect(watcher, &QDBusPendingCallWatcher::finished, exitLoop); loop.exec(); + QTimer::singleShot(timeout, this, &ExternalCommand::quit); + return rval; } @@ -339,6 +340,12 @@ void ExternalCommand::setExitCode(int i) d->m_ExitCode = i; } +/**< Dummy function for QTimer when needed. */ +void ExternalCommand::quit() +{ + +} + bool ExternalCommand::startHelper() { if (!QDBusConnection::systemBus().isConnected()) { diff --git a/src/util/externalcommand.h b/src/util/externalcommand.h index be56818..c36c42e 100644 --- a/src/util/externalcommand.h +++ b/src/util/externalcommand.h @@ -104,6 +104,9 @@ public: void emitReport(const QVariantMap& report) { emit reportSignal(report); } + /**< Dummy function for QTimer when needed. */ + void quit(); + // KAuth /**< start ExternalCommand Helper */ bool startHelper();