-
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
Comments not recorded in delete event #1960
Comments
@kchadha FYI |
Investigated some. The problem is that BlockSVG.dispose disposes of the icons before super.dispose which is where the delete event gets recorded. Since the icon owns the comment the comment gets destroyed before we can save it. Short term I'll investigate if we can just destroy the icons after calling super, but long term the icon probably shouldn't own the comment like that. |
The icons in rendered Blockly currently own the comment text. When a block was deleted the icons were being disposed of before the block info was recorded in the event, which meant the comment was lost. This adds some additional logic to block_svg to make sure the event is captured before the icons are removed.
The icons in rendered Blockly currently own the comment text. When a block was deleted the icons were being disposed of before the block info was recorded in the event, which meant the comment was lost. This adds some additional logic to block_svg to make sure the event is captured before the icons are removed.
Disabled for now as it fails due to google#1960.
Disabled for now as it fails due to google#1960.
Disabled for now as it fails due to #1960.
The fix was rolled back as it broke other things. |
I ran into this when I was testing the trashcan contents, and I was wondering, is there any reason why we couldn't just dispose of the block before disposing of the icons? i.e.:
instead of:
I did a quick test and I think it would work. I couldn't replicate the error found in #1970, and I don't believe any of the functions following the superClass_.dispose() call would access the block, but it does seem like it would be a bit of a silly thing to do. Here's the link to the relevant .dispose() function. Edit: I went back and looked at #1970 & #1972 and I believe the only problem is that it needs to call this.unplug(healStack) before creating the delete event. I did a quick check and there were no more errors. |
@RoboErikG you were looking at this earlier. Does this fix make sense to you? |
As far as I can tell it would work, but I'm really hesitant to call the super's dispose before the specific dispose. It's typically an implied part of the API that more general cleanup code gets called after the specific cleanup code. I'd be okay with making this as a temporary fix with a TODO to move the super's dispose down again once we separate out the comment's model and UI. |
We could also use the old fix, and just add this.unplug(healStack) before creating the delete event. If we were to add that, the blocks wouldn't be connected anymore so we wouldn't get the error from #1972. (Tested and confirmed) You can see how block.js does this inside it's dispose function. If we were to do that it would preserve the cleanup order, as well as fix the issue. |
I like that solution more, and there shouldn't be any issues with unplug being called twice. =) |
In the playground, turn on event logging and open the console.
Create any block (I'll use 'not' in this example) and place it on the workspace.
Add a 'hello world' comment to this block. Note that a Change event is correctly created.
Delete the block. Note that the Delete event's oldXML.outerHTML lacks the comment:
Then if undo is executed, the block reappears without the comment.
This is not a regression.
The text was updated successfully, but these errors were encountered: