-
Notifications
You must be signed in to change notification settings - Fork 164
Create Font handles on demand #2087
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
e4b1bad
to
1a72888
Compare
@ShahzaibIbrahim I once played around with making Fonts GC disposable here: do you think that would be applicable here as well? So wrapping the (long) handle inside an
in the code. |
@laeubi I personally like the idea. I could implement it, but just to be consistent with other resources in win32. I would like it to be handled as I have done with isDestoyed field. Maybe we could do it for all the resources in a separate issue/ticket. |
c76ad30
to
d1337cf
Compare
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.
I marked the new field fontData
as final
(and explicitly initialized it to null
in 2 constructors). The code looks OK but some tests fail because when fontData == null
, the newly added static method does an illegal call.
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Font.java
Show resolved
Hide resolved
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.
This PR is currently broken. The first commit is supposed to be an independent refactoring, but the code state does not compile.
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Font.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Font.java
Show resolved
Hide resolved
f95af17
to
4e94765
Compare
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.
Now the commit contents are the wrong way round and do not fit their commit messages: the first, refactoring commit contains the actual change (creating handles on demand) and the second change supposed to create handles on demand encapsulates the field and adds some additional checks and corrects formatting.
4e94765
to
25aa844
Compare
The handle of Font is encapsulated and exposed only via static method win32_getHandle and direct access to the field is replaced by access to that method.
Handles will no longer be created during initialization but upon first access to the handle via its accessor. Also the destroy condition is changed since handle being 0 doesn't mean that it was destroyed anymore.
Creating a new static method to retrieve font handle. Handles will no longer be created during initialization. Also destroy condition is changed since handle being 0 doesn't mean that it was destroyed anymore.
How to test