-
Notifications
You must be signed in to change notification settings - Fork 190
[Win32] Check widget for disposal before zoom change notification #3047
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
Conversation
|
Thanks for providing a fix for that!
I'm not sure its relevant here but I mostly see it during remote-desktop sessions when connecting from different computers. So in this particular case it might be that the image needs to be refreshed. |
As a DPI change event seems to be triggered in that case (according to the stack trace with the disposed error), images should automatically be refreshed via the DPI change handlers. If you notice that anything is wrong with the images, please let me know. |
d96f3d8 to
87e0c20
Compare
|
It all seems to work except that ones get an error dialog on DPI change, after dismiss the dialog everything is working. |
The dialog pops up because of the error reported in #3043, or is there anything else? |
Yes it seems to be a standard error dialog of Eclipse (with just text "Widget Disposed") then one can dismiss and application seem to work (but maybe have missed some updates of course). It might be become visible now the automatic scaling is the default? |
That might be the case, yes. If I understand the description in the issue correctly, it's a pure E4 application, which was (by accident) not affected by the default enablement via preference we had introduced more than half a year ago. So it might be affected by the recent change of SWT to use monitor-specific scaling by default. The arising question is of course why there is a disposed TreeItem at all. It might be that this disposed item has been there by accident already before, but that it did not lead to any issues as no one has accessed it. That changed now with the DPI change processing being applied and accessing the item, which reveals that disposed state. |
SWT has the concept of virtual Table/Tree (using |
|
Sounds like a reasonable guess, but not that easy to verify. And assuming it's correct, just ignoring disposed elements for updates on DPI changes seems fine to me. So should we go with this change? You could then report if the error dialog still pops up for you or if you face any other issues with the trees in your application afterwards. |
|
Yes I think just ignore them would make sense here. |
fedejeanne
left a comment
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.
The code looks good, I just have some questions:
- Doesn't this call also need a check?
eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java
Line 1775 in c891c43
| item.notifyListeners(SWT.ZoomChanged, event); |
- Would it make sense to check for
event.doitlike it's being done inControl::sendZoomChangeEventjust in case someone decides to stop the propagation (for whatever reason)?
eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
Line 6121 in c891c43
| if (!this.isDisposed() && event.doit) { |
- Doesn't the call in
Shellalso need a check? I suppose shell is a special case but I just want to check:
eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java
Line 2534 in c891c43
| notifyListeners(SWT.ZoomChanged, zoomChangedEvent); |
bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java
Show resolved
Hide resolved
In most scenarios, zoom change processing happens asynchronously. In consequence, widgets may evolve and even already be disposed until a notification for a zoom change event on them actually is processed. This can lead to disposed widget exceptions in case such a notification is sent on an already disposed widget. This change adapts all places that send zoom change notification on DPI change to check for disposal of the widget to send the notification to first. Fixes eclipse-platform#3043
87e0c20 to
f6ef9c7
Compare
|
Thank you for the feedback. The proposed extraction into a separate method definitely makes sense. I have adapted the PR accordingly.
I thought about whether we need a check here as well. The reason why I didn't add it is because the code around that refreshes (or rather recreates) the tool button would actually fail if the item was disposed. When taking a deeper look, I even think that this line of code might be completely useless. The buttons are recreated anyway and the
This method is only called when a WM_DPICHANGED event is triggered on the shell, which can only happen if the shell is not disposed. |
|
Thank you for the clarifications!
Makes sense to postpone the change to M1 to avoid surprises if the current state doesn't hurt 👍
Ah, ok. I was mistakenly assuming that the changes were split into several smaller async calls and that there was a (near-zero) chance that some newer DPI change event would happen while processing the older DPI change event.
Makes sense 👍 |
|
All good from my side. @laeubi may we merge this one? |
|
You both have commit rights here and as there is no disagreement and its fixing a bug I think it can be merged as soon as you like. |
In most scenarios, zoom change processing happens asynchronously. In consequence, widgets may evolve and even already be disposed until a notification for a zoom change event on them actually is processed. This can lead to disposed widget exceptions in case such a notification is sent on an already disposed widget.
This change adapts all places that send zoom change notification on DPI change to check for disposal of the widget to send the notification to first.
Fixes #3043