summaryrefslogtreecommitdiffstats
path: root/src/libs/installer/elevatedexecuteoperation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/installer/elevatedexecuteoperation.cpp')
-rw-r--r--src/libs/installer/elevatedexecuteoperation.cpp34
1 files changed, 14 insertions, 20 deletions
diff --git a/src/libs/installer/elevatedexecuteoperation.cpp b/src/libs/installer/elevatedexecuteoperation.cpp
index 5de3c0203..3f3cdbb2a 100644
--- a/src/libs/installer/elevatedexecuteoperation.cpp
+++ b/src/libs/installer/elevatedexecuteoperation.cpp
@@ -63,8 +63,9 @@ public:
bool showStandardError;
};
-ElevatedExecuteOperation::ElevatedExecuteOperation()
- : d(new Private(this))
+ElevatedExecuteOperation::ElevatedExecuteOperation(PackageManagerCore *core)
+ : UpdateOperation(core)
+ , d(new Private(this))
{
// this operation has to "overwrite" the Execute operation from KDUpdater
setName(QLatin1String("Execute"));
@@ -79,12 +80,9 @@ bool ElevatedExecuteOperation::performOperation()
{
// This operation receives only one argument. It is the complete
// command line of the external program to execute.
- if (arguments().isEmpty()) {
- setError(InvalidArguments);
- setErrorString(tr("Invalid arguments in %0: %1 arguments given, %2 expected%3.")
- .arg(name()).arg(arguments().count()).arg(tr("at least 1"), QLatin1String("")));
+ if (!checkArgumentCount(1, INT_MAX))
return false;
- }
+
QStringList args;
foreach (const QString &argument, arguments()) {
if (argument!=QLatin1String("UNDOEXECUTE"))
@@ -144,7 +142,7 @@ bool ElevatedExecuteOperation::Private::run(const QStringList &arguments)
const bool success = QProcessWrapper::startDetached(args.front(), args.mid(1));
if (!success) {
q->setError(UserDefinedError);
- q->setErrorString(tr("Execution failed: Could not start detached: \"%1\"").arg(callstr));
+ q->setErrorString(tr("Cannot start detached: \"%1\"").arg(callstr));
}
return success;
}
@@ -163,12 +161,12 @@ bool ElevatedExecuteOperation::Private::run(const QStringList &arguments)
if (showStandardError)
process->setProcessChannelMode(QProcessWrapper::MergedChannels);
- connect(q, SIGNAL(cancelProcess()), process, SLOT(cancel()));
+ connect(q, &ElevatedExecuteOperation::cancelProcess, process, &QProcessWrapper::cancel);
//we still like the none blocking possibility to perform this operation without threads
QEventLoop loop;
if (QThread::currentThread() == qApp->thread()) {
- QObject::connect(process, SIGNAL(finished(int, QProcess::ExitStatus)), &loop, SLOT(quit()));
+ QObject::connect(process, &QProcessWrapper::finished, &loop, &QEventLoop::quit);
}
//readProcessOutput should only called from this current Thread -> Qt::DirectConnection
QObject::connect(process, SIGNAL(readyRead()), q, SLOT(readProcessOutput()), Qt::DirectConnection);
@@ -196,7 +194,7 @@ bool ElevatedExecuteOperation::Private::run(const QStringList &arguments)
if (!success) {
q->setError(UserDefinedError);
//TODO: pass errorString() through the wrapper */
- q->setErrorString(tr("Execution failed: Could not start: \"%1\"(%2)").arg(callstr,
+ q->setErrorString(tr("Cannot start: \"%1\": %2").arg(callstr,
process->errorString()));
returnValue = false;
}
@@ -212,14 +210,14 @@ bool ElevatedExecuteOperation::Private::run(const QStringList &arguments)
if (process->exitStatus() == QProcessWrapper::CrashExit) {
q->setError(UserDefinedError);
- q->setErrorString(tr("Execution failed(Crash): \"%1\"").arg(callstr));
+ q->setErrorString(tr("Program crashed: \"%1\"").arg(callstr));
returnValue = false;
}
if (!allowedExitCodes.contains(process->exitCode())) {
q->setError(UserDefinedError);
if (customErrorMessage.isEmpty()) {
- q->setErrorString(tr("Execution failed(Unexpected exit code: %1): \"%2\"")
+ q->setErrorString(tr("Execution failed (Unexpected exit code: %1): \"%2\"")
.arg(QString::number(process->exitCode()), callstr));
} else {
q->setErrorString(customErrorMessage);
@@ -228,13 +226,14 @@ bool ElevatedExecuteOperation::Private::run(const QStringList &arguments)
QByteArray standardErrorOutput = process->readAllStandardError();
// in error case it would be useful to see something in verbose output
if (!standardErrorOutput.isEmpty())
- qWarning() << standardErrorOutput;
+ qWarning().noquote() << standardErrorOutput;
returnValue = false;
}
Q_ASSERT(process);
- process->deleteLater();
+ Q_ASSERT(process->state() == QProcessWrapper::NotRunning);
+ delete process;
process = 0;
return returnValue;
@@ -289,11 +288,6 @@ bool ElevatedExecuteOperation::testOperation()
return true;
}
-Operation *ElevatedExecuteOperation::clone() const
-{
- return new ElevatedExecuteOperation;
-}
-
void ElevatedExecuteOperation::backup()
{
}