New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Runtime validation and error reporting #46
Conversation
…ut data from all the nodes, makes code generation based on the graphs easier.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, a few minor comments
Really cool feature, can't wait to use it on my own project.
@@ -45,7 +48,7 @@ class DivisionModel : public MathOperationDataModel | |||
default: | |||
break; | |||
} | |||
return QString(""); | |||
return QString(""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 for indentation, not tab+2 spaces
@@ -56,6 +59,14 @@ class DivisionModel : public MathOperationDataModel | |||
clone() const override | |||
{ return std::make_unique<DivisionModel>(); } | |||
|
|||
virtual | |||
bool | |||
isValid() const { return isModelValid; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
override
|
||
virtual | ||
QString | ||
errorMessage() const { return modelValidationError; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again override
@@ -65,7 +76,13 @@ class DivisionModel : public MathOperationDataModel | |||
} | |||
|
|||
private: | |||
|
|||
void | |||
setValidationState(bool isValid, const QString &msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this function needed? It just manipulates private member variables and doesn't do anything special....
_result.reset(); | ||
setValidationState(true, | ||
QString("")); | ||
if (n1 && n2 && (n2->number() != 0.0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last condition will never be true because it's checked on L94
…minor styling and logic fixes in the example, based on the comments of @russelltg
Thanks for the feedback, I fixed the things you mentioned (I probably forgot to double check this file before I sent the pull request). On top of this there was a minor bug in the drawing logic that now got fixed: if you check the calculator example, the result node doesn't resize correctly if its value changes from empty to some number. (If you pull the mouse over it, that forces a refresh.) I already implemented a solution that handled this kind of size change, but it only ran if the validation state changed, so I removed the condition check from it to handle all kinds of data dependent size change. Theoretically recalculation could be a teeny bit slower because of this, but I think the size of the graph becomes unmanagable for the endusers much before this slowdown could be significant. (Although a check could be implemented, so that we only force an update when the size really changed.) |
👍 LGTM |
I actually just had an idea. If |
Good idea, but instead of checking the message for content, I've changed isValid into returning an enum value. It's clearer, and easily extensible to handle additional validation states. (Multiple different warning levels for example.) I'm in the process of refactoring the entire branch to use this consistently, so a second full review after the commit would probably be a good idea. |
…; Error display colors now come from the style system; Additional bugfixes
Review status: 2 of 19 files reviewed at latest revision, 6 unresolved discussions, some commit checks broke. examples/calculator/DivisionModel.hpp, line 51 at r1 (raw file): Previously, russelltg (Russell Greene) wrote…
Done. examples/calculator/DivisionModel.hpp, line 64 at r1 (raw file): Previously, russelltg (Russell Greene) wrote…
Done. examples/calculator/DivisionModel.hpp, line 68 at r1 (raw file): Previously, russelltg (Russell Greene) wrote…
Done. examples/calculator/DivisionModel.hpp, line 80 at r1 (raw file): Previously, russelltg (Russell Greene) wrote…
Done. examples/calculator/DivisionModel.hpp, line 103 at r1 (raw file): Previously, russelltg (Russell Greene) wrote…
Done. src/FlowScene.cpp, line 224 at r2 (raw file): Previously, russelltg (Russell Greene) wrote…
Done. Comments from Reviewable |
Travis build is working again, it looks like the qt5.7 repository path changed, correcting it seemingly fixed the issue. |
Comments from Reviewable |
I really like this, I hope @paceholder merges this 👍 |
I really like the idea and was thinking of implementing something like that. The only concern I have is the visualization: it looks heavy and changes geometry. Maybe it is worth to show the incorrect input just by highlighting the input circle with red? So, I will merge it for now and will think how to improve the graphics. And yes, thanks for the effort. |
Idea: if the node is in a validation state that is not Valid, we put a small square in one of the nodes corner with a ! in it, and a yellow or red background color. If the user clicks on this square a bigger square pops out next to the node, containing the validation message. This would allow longer messages without serious change to the nodes visuals it self. Would this solve the problem? I've planned to implement something like this for help info/documentation on nodes, if I manage to get around doing it, it could easily be repurposed for the validation messages too.
This could be done, and it would look good, but for this to work, the node validation part must be rewritten. The current solution validates the node as a whole, not the individual ports. Changing the validationState and validationMessage functions to have a port index and port type param should do the trick from an interface perspective. |
Extension to the library to provide a way to handle internal node errors in a more visible way. Nodes now have a chance to implement a kind of self validation mechanism, and report to the scene if the operation they representing is not possible on the data they contain. (Example in the calculator sample, if the division node gets a 0 value on the divisor port, that now results in a validation error.) In case of an error, the reported error message if displayed on the invalid node.
Additionally there's a minor modification to create an easy way to iterate through all the existing nodes in the scene.
This change is