Commit 5caf8790 authored by Lukas Appelhans's avatar Lukas Appelhans
Browse files

Actually do proper error handling when validating... not just running endlessly

parent 1958f1b8
......@@ -28,6 +28,7 @@ void OperationPrivate::concurrentValidate()
{
Q_Q(Operation);
validateLoop = new QEventLoop;
status = Operation::StatusValidating;
q->validate();
if (status == Operation::StatusValidating) {
validateLoop.data()->exec();
......@@ -52,7 +53,7 @@ void OperationPrivate::setStatus(Operation::Status newstatus)
if (status != newstatus) {
Q_Q(Operation);
status = newstatus;
emit runner->operationStatusChanged(q, status);
//emit runner->operationStatusChanged(q, status);
}
}
......@@ -257,7 +258,6 @@ void Operation::setFinished(bool result)
d->setStatus(StatusError);
}
if (!d->runLoop.isNull()) {
qDebug() << "Quit the loop";
d->runLoop.data()->quit();
}
}
......
......@@ -28,6 +28,8 @@
#define ERRORS_CHECKPOINT() if (!errors.isEmpty()) { \
manageErrors(errors); \
return; }
static QWeakPointer<QFutureWatcher< void > > s_validateFutureWatcher;
namespace Akabei {
......@@ -63,6 +65,13 @@ OperationPrivate* ValidatorRunnable::operationPrivateProxy(Operation* op)
void concurrentValidate(Operation* op)
{
ValidatorRunnable::operationPrivateProxy(op)->concurrentValidate();
// How did it go?
if (op->status() == Operation::StatusReady) {
// It's ok!
} else if (!s_validateFutureWatcher.isNull()) {
s_validateFutureWatcher.data()->cancel();
}
}
void ValidatorRunnable::requestCancel()
......@@ -149,14 +158,26 @@ void ValidatorRunnable::processNextPhase()
// Start the concurrent validation
QEventLoop e;
QFutureWatcher< void > watcher;
connect(&watcher, SIGNAL(finished()), &e, SLOT(quit()));
connect(&watcher, SIGNAL(progressValueChanged(int)), this, SLOT(streamValidationProgress(int)));
s_validateFutureWatcher = new QFutureWatcher<void>();
connect(s_validateFutureWatcher.data(), SIGNAL(finished()), &e, SLOT(quit()));
connect(s_validateFutureWatcher.data(), SIGNAL(progressValueChanged(int)), this, SLOT(streamValidationProgress(int)));
QFuture< void > future = QtConcurrent::map(processOps, concurrentValidate);
watcher.setFuture(future);
s_validateFutureWatcher.data()->setFuture(future);
e.exec();
QList<Error*> errors;
if (s_validateFutureWatcher.data()->isCanceled()) {
// Manage errors...
foreach (Operation *op, processOps) {
errors << op->errors();
}
}
s_validateFutureWatcher.data()->deleteLater();
// Good. Any errors?
ERRORS_CHECKPOINT()
// Now populate target names and dependencies
QHash< QString, Operation* > processTargetNames;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment