-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
fix: disposing of a workspace that has overwritten shadows #6424
Conversation
I think it might actually be safest to add an internal But on the other hand, I hate using state to define functional logic. So Imma sleep on it. |
core/block.ts
Outdated
@@ -356,7 +357,6 @@ export class Block implements IASTNodeLocation, IDeletable { | |||
} | |||
} finally { | |||
eventUtils.enable(); | |||
this.disposed = true; |
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.
Do you know where the exception this try/catch is wrapping is thrown? Do we still need this here in case it throws prior to disposed being set to true in the try?
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.
Ha no. Back in 2016 a contributor just wrapped everything between an Events.disable()
and an Events.enable()
in a try...finally
to make sure that events were always re-enabled: #348
The basics
npm run format
andnpm run lint
The details
Resolves
Part of #6358
Proposed Changes
Change where we set
block.disposed
totrue
. I audited all of the places wheredisposed
is referenced, and I don't think this will break anything. But let's be honest, it probably will break something.Behavior Before Change
If you disposed of a workspace that had an overwritten shadow block in it, the workspace would throw an error. See #6358 (comment)
No end-user-facing change in behavior.
Behavior After Change
No Error!
No end-user-facing change in behavior.
Reason for Changes
Errors are sad =(
Test Coverage
Manually tested that disposing of a workspace with the following blocks in it did not cause an error to be thrown:
Documentation
N/A
Additional Information
Caused by https://github.com/google/blockly/pull/6300/files#diff-dd85563e074ebb74e4c34eee01568971430f3cb7a6b846feef8044ad8d5dcd61L566
The issue is that
workspace
used to be set tonull
before the blocks were disposed, so that would properly causecreateShadowBlock_
to short circuit. But becausecreateShadowBlock_
was now looking atdisposed
it wasn't short circuiting, becausedisposed
was set after the blocks were disposed.