Skip to content
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

Merged
merged 7 commits into from Jan 25, 2017

Conversation

LandonJerre
Copy link
Contributor

@LandonJerre LandonJerre commented Jan 20, 2017

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.
errormsg
Additionally there's a minor modification to create an easy way to iterate through all the existing nodes in the scene.


This change is Reviewable

@LandonJerre LandonJerre changed the title Runtimeerrors Runtime validation and error reporting Jan 20, 2017
Copy link
Contributor

@russelltg russelltg left a 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("");
Copy link
Contributor

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; }
Copy link
Contributor

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; }
Copy link
Contributor

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)
Copy link
Contributor

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))
Copy link
Contributor

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
@LandonJerre
Copy link
Contributor Author

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.)

@russelltg
Copy link
Contributor

👍 LGTM

@russelltg
Copy link
Contributor

I actually just had an idea. If isValid returns true and the error message is set, that could be a warning, displayed in yellow. That would be cool and useful (at least for me...)

@LandonJerre
Copy link
Contributor Author

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
@LandonJerre
Copy link
Contributor Author

The end result visually:
eg
The travis build magically failed, looking at the log it looks like it's not a compilation error.

@LandonJerre
Copy link
Contributor Author

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…

2 for indentation, not tab+2 spaces

Done.


examples/calculator/DivisionModel.hpp, line 64 at r1 (raw file):

Previously, russelltg (Russell Greene) wrote…

override

Done.


examples/calculator/DivisionModel.hpp, line 68 at r1 (raw file):

Previously, russelltg (Russell Greene) wrote…

again override

Done.


examples/calculator/DivisionModel.hpp, line 80 at r1 (raw file):

Previously, russelltg (Russell Greene) wrote…

Is this function needed? It just manipulates private member variables and doesn't do anything special....

Done.


examples/calculator/DivisionModel.hpp, line 103 at r1 (raw file):

Previously, russelltg (Russell Greene) wrote…

The last condition will never be true because it's checked on L94

Done.


src/FlowScene.cpp, line 224 at r2 (raw file):

Previously, russelltg (Russell Greene) wrote…

2 tabs for indentation

Done.


Comments from Reviewable

@LandonJerre
Copy link
Contributor Author

Travis build is working again, it looks like the qt5.7 repository path changed, correcting it seemingly fixed the issue.

@russelltg
Copy link
Contributor

russelltg commented Jan 25, 2017

:lgtm:


Comments from Reviewable

@russelltg
Copy link
Contributor

I really like this, I hope @paceholder merges this 👍

@paceholder
Copy link
Owner

paceholder commented Jan 25, 2017

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?
And show "no data propagation" with graying out the nodes without the valid data?

So, I will merge it for now and will think how to improve the graphics.

And yes, thanks for the effort.

@paceholder paceholder merged commit 770a1aa into paceholder:master Jan 25, 2017
@LandonJerre LandonJerre deleted the runtimeerrors branch January 25, 2017 11:23
@LandonJerre
Copy link
Contributor Author

The only concern I have is the visualization: it looks heavy and changes geometry.

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.

Maybe it is worth to show the incorrect input just by highlighting the input circle with red?
And show "no data propagation" with graying out the nodes without the valid data?

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants