-
-
Notifications
You must be signed in to change notification settings - Fork 205
Add weak reference support to freetype.Font #3596
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
📝 WalkthroughWalkthroughAdds weak-reference support to the FreeType Font type by introducing a weak reference list field in pgFontObject, wiring tp_weaklistoffset, initializing the field in the constructor, and clearing weak refs in deallocation. A new test verifies weakref clearing upon GC. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Py as Python code
participant FT as ft.Font
participant Obj as pgFontObject
participant WR as weakref.ref
participant GC as PyGC
Py->>FT: create Font(path)
FT-->>Obj: allocate + init (weakreflist=NULL)
Py->>WR: weakref.ref(Obj)
Py->>Py: del strong ref to Obj
Py->>GC: gc.collect() x2
GC->>Obj: dealloc()
note right of Obj: PyObject_ClearWeakRefs(self)
Obj-->>WR: invalidate target
WR-->>Py: returns None on call/deref
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
🧰 Additional context used🪛 Ruff (0.13.1)test/freetype_test.py1611-1611: Loop control variable (B007) ⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
🔇 Additional comments (5)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🧪 Early access (Sonnet 4.5): enabledWe are currently testing the Sonnet 4.5 model, which is expected to improve code review quality. However, this model may lead to increased noise levels in the review comments. Please disable the early access features if the noise level causes any inconvenience. Note:
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.
Same as your last commit. Thank you. +1
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.
LGTM, thanks for contributing! 🎉
Following the template of #3590, adding weak reference support to freetype.Font.
This aims to bring freetype.Font to parity with pygame.Font with respect to weak references.