Commit 5b7d7c2e authored by NICLAUSSE Nicolas's avatar NICLAUSSE Nicolas

Check if all object nodes have an implementation choosen.

parent a4623474
......@@ -12,9 +12,9 @@
// Code:
#include "dtkComposerEvaluator.h"
#include "dtkComposerGraph.h"
#include "dtkComposerNodeComposite.h"
#include "dtkComposerNodeLeaf.h"
#include "dtkComposerReader.h"
#include "dtkComposerScene.h"
#include "dtkComposerScene_p.h"
......@@ -429,6 +429,32 @@ QList<dtkComposerSceneNodeLeaf *> dtkComposerScene::flagged(Qt::GlobalColor colo
return d->flagged_nodes[color];
}
bool dtkComposerScene::checkImplementations(void)
{
populateNodes();
foreach (dtkComposerSceneNode * node, d->all_nodes) {
if (dtkComposerNodeLeafObject *nobj = dynamic_cast<dtkComposerNodeLeafObject*>(node->wrapee())) {
if (nobj->currentImplementation().isEmpty()) {
QMessageBox msgBox;
msgBox.setText("Node implementation is missing. Run anyway?");
msgBox.setInformativeText("A node has no implementation set, an execution may give you random results or a crash !");
QString msg = QString("The following node is missing an implementation: %1.\nAvailable implementations:\n%2").
arg(node->title()).
arg(nobj->implementations().join("\n"));
msgBox.setDetailedText(msg);
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Cancel);
if(msgBox.exec() == QMessageBox::Cancel)
return false;
}
}
}
return true;
}
// /////////////////////////////////////////////////////////////////
#pragma mark -
#pragma mark - Sig Events
......@@ -1241,5 +1267,25 @@ void dtkComposerScene::populateEdges(dtkComposerSceneNode *node)
}
}
void dtkComposerScene::populateNodes(dtkComposerSceneNode *node)
{
if (!node) {
node = d->root_node;
d->all_nodes.clear();
}
d->all_nodes << node;
if(dtkComposerSceneNodeComposite *composite = dynamic_cast<dtkComposerSceneNodeComposite *>(node))
foreach(dtkComposerSceneNode *child, composite->nodes())
this->populateNodes(child);
if(dtkComposerSceneNodeControl *control = dynamic_cast<dtkComposerSceneNodeControl *>(node)) {
foreach(dtkComposerSceneNodeComposite *block, control->blocks())
this->populateNodes(block);
}
}
//
// dtkComposerScene.cpp ends here
......@@ -87,6 +87,7 @@ public:
public:
QList<dtkComposerSceneNodeLeaf *> flagged(Qt::GlobalColor);
bool checkImplementations(void);
public:
bool maskedEdges(void);
......@@ -166,6 +167,7 @@ protected:
protected:
void populateEdges(dtkComposerSceneNode *root = NULL);
void populateNodes(dtkComposerSceneNode *root = NULL);
// #pragma mark -
// #pragma mark - Internal sigs handling
......
......@@ -51,6 +51,7 @@ public:
public:
dtkComposerSceneEdgeList connected_edges;
dtkComposerSceneEdgeList all_edges;
dtkComposerSceneNodeList all_nodes;
public:
bool masked_edges;
......
......@@ -242,7 +242,9 @@ void dtkComposerWidget::run(void)
{
this->updateRemotes(d->scene->root());
QtConcurrent::run(d->evaluator, &dtkComposerEvaluator::run, false);
if (d->scene->checkImplementations()) {
QtConcurrent::run(d->evaluator, &dtkComposerEvaluator::run, false);
}
}
void dtkComposerWidget::step(void)
......
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