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

Correct disposal implementation for exception widget #22782

Closed
wants to merge 2 commits into from
Closed

Correct disposal implementation for exception widget #22782

wants to merge 2 commits into from

Conversation

michelkaporin
Copy link
Contributor

I believe the reason for the the exception is that _viewZone was disposed meanwhile it was scheduled to relayout. Added null check for _viewZone. Correct me if I am wrong.

Fixes #22607

@michelkaporin michelkaporin requested a review from isidorn March 17, 2017 08:05
@msftclas
Copy link

@michelkaporin,
Thanks for having already signed the Contribution License Agreement. Your agreement was validated by Microsoft. We will now review your pull request.
Thanks,
Microsoft Pull Request Bot

@isidorn
Copy link
Contributor

isidorn commented Mar 17, 2017

@michelkaporin the issue here is that you are using a scheduler with a 50ms which can happen after the widget is disposed.
I would prefer a proper fix which is that you cancel and dispose the scheduler in your dipose method(or just add the scheduler in the this_disposabels).

@michelkaporin
Copy link
Contributor Author

Pushed the proper change, thanks for the advice @isidorn!

@michelkaporin michelkaporin changed the title Added null check in case if viewZone is disposed. Correct disposal implementation for exception widget Mar 17, 2017
@isidorn
Copy link
Contributor

isidorn commented Mar 17, 2017

@michelkaporin I think you misunderstood me, you do not need to care about disposing disposables, that should be nicely done by the super class.
You shuold simply add your scheduler to the disposables and everything should be dispoed perfectly

@michelkaporin
Copy link
Contributor Author

michelkaporin commented Mar 17, 2017

@isidorn In fact it is already added in the constructor.
https://github.com/michelkaporin/vscode/blob/be3d0cf945bbad51ade31d81c760e90307c633b3/src/vs/workbench/parts/debug/browser/exceptionWidget.ts#L26

My second commit is anyway redundant then. In addition, when the dispose method is called on the scheduler, it cancels it before disposing.

I've looked at the code flow again and it seems that the problem lies not in the fact that _viewZone was disposed and scheduler not, as I thought initially. It seems to be that the scheduler was created and called before the _viewZone was instantiated with zoneWidget.show() method. I will revert the last commit back to be3d0cf which looks like a correct fix for me in this scenario, do you agree?

@isidorn
Copy link
Contributor

isidorn commented Mar 17, 2017

@michelkaporin sometimes it is easier to communicate in code, here's what I meant 1bd0389

The difference that you already have a listener to schedule the scheduler to be disposed, but not the scheduler itself. The difference is the following

An event happens and you schedule
20 ms later you get diposed - you dipose the listener but the scheduler is still alive and kicking
30 ms later scheduler kicks in and does stuff on on invalid object

@isidorn isidorn closed this Mar 17, 2017
@michelkaporin
Copy link
Contributor Author

@isidorn Makes sense now. Sorry, I was wrongly assuming that I am disposing the scheduler, whereas it was a listener. Thanks for explanation.

@isidorn
Copy link
Contributor

isidorn commented Mar 17, 2017

@michelkaporin no worries, welcome.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Uncaught TypeError: Cannot read property 'heightInLines' of null
3 participants