Create a timer to wait for system to free resources

Reviewers: stikonas

Reviewed By: stikonas

Differential Revision: https://phabricator.kde.org/D21696
This commit is contained in:
Shubham Jangra 2019-06-09 22:10:15 +05:30
parent ef20244be5
commit 2627d476f4
2 changed files with 12 additions and 2 deletions

View File

@ -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()) {

View File

@ -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();