-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Make CanvasItem's "drawing outside of NOTIFICATION_DRAW" error a macro #89298
Make CanvasItem's "drawing outside of NOTIFICATION_DRAW" error a macro #89298
Conversation
fcfeebf
to
e4b908e
Compare
e4b908e
to
9d95596
Compare
I do not have the capacity to test any of this so I just stripped the DEBUG_ENABLED |
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.
LGTM
Worth doing a future pass to see if it's something to make a debug only check, but generally we don't make that distinction unless it's very development side, if it's possible without weird side effects it'd be worth considering, but since the check is so cheap I don't think it's worth evaluating on it's own, maybe a future sweep for different checks would be something to consider
This should resolve #75376. But maybe the error message should also explicitly state what |
I do agree and I tried to do that. Problem is I just couldn't find a nice "spot" to explicitly state both. |
|
Yeah, that one cannot be done. But the node name can. I wouldn't want the error to be too verbose as it will be prone to get spammed in the debugger. Not pretty, so I gotta be careful. |
Risks causing unhelpful editor paths indeed, like parenting errors at times |
9d95596
to
05afbb8
Compare
Applied both suggestions. Note that the ERR_THREAD_GUARDs are not formatted the same way. |
05afbb8
to
e44927a
Compare
e44927a
to
e08fb19
Compare
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.
Re-confirming, let's take a look later at a standardized and low-clutter way to convey where errors occur as per the suggestions above, but looks good just as a cleanup
Not really, you can call extends Node2D
func _draw():
# When this is called `current_item_drawn` is `self`.
some_other_canvas_item.draw_circle(...) # Any `draw_x` method called on non-self canvas item.
# Error: "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal."
# User: What do you mean?! It is in `_draw()`... The error being changed to:
already makes the error message correct/clearier. 👍 Regarding further improvement - yeah, I agree it's out of scope of this PR. I'm also not sure what would be a good way to refer to the problematic nodes. Path seems too long, just names too vague, BTW it could be also considered to have slightly different error messages depending on the case, like: ERR_FAIL_COND_MSG(current_item_drawn == nulltpr, "..."); // Not in drawing routine at all.
ERR_FAIL_COND_MSG(current_item_drawn != this, "..."); // In drawing routine of a different CanvasItem. ( Wondering if something like this could make things clearer even if not directly specifying what canvas item(s) this happened for. But also not sure how doubling the checks would affect performance. Just a thought, not saying it should be done in here. This PR is fine as is. |
Speaking of the much prior topic, if only checking for |
Thanks! |
The premise is simple:
Imagine this but 25 times.
I also took the chance to improve upon the error message itself. At least, attempted to.
Please give suggestions for a better macro name, I do not know the pattern.
Resolves #75376.