-
Notifications
You must be signed in to change notification settings - Fork 185
Initialization handles without creating a Cursor instance #2378
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
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.
We now have three mutually exclusive fields (source, imageDataProvider and style). Only one of them is set, depending on how the cursor was initialized. And there are three setup... methods that can be executed depending on which of those three fields is set.
Can't we wrap that into something like a CursorHandleProvider interface, which has three implementations, each just accepting the necessary information (ImageData, ImageDataProvider or int/style) and then creating the handle based on that specific information. That would avoid that we always have two unused fields and that we need to switch logic depending on which of them is set.
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Cursor.java
Outdated
Show resolved
Hide resolved
Good Idea, we can do it perhaps after we are done fixing this issue, in a separate PR? |
Yes, we can do that. But then we should probably leave out the addition of the |
339f09d to
2e9f45b
Compare
2e9f45b to
cda99e3
Compare
In win32_getHandle, a new cursor instance is created to retrieve the OS handle. With this change, we are able to safely retrieve the handle without creating a cursor instance.
cda99e3 to
6ce1c2d
Compare
In win32_getHandle, a new cursor instance is created to retrieve the OS handle. With this change, we are able to safely retrieve the handle without creating a cursor instance.
How to Reproduce
To reproduce the issue, run the following snippet with resource tracking turned on:
-Dorg.eclipse.swt.graphics.Resource.reportNonDisposed=trueYou will see the following error:
Expected Result
With this PR, there should be no
NonDisposeResourceerror since we are now not creating a new Cursor instance to retrieve the handle.Fixes: #2355