You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dragging the edges of the window to resize the example app (at least on macOS) generates repeated instances of this error:
Exception ignored on calling ctypes callback function <rubicon.objc.api.objc_method object at 0x10718c600>:
Traceback (most recent call last):
File "/Users/charles/.pyenv/versions/toga_313/lib/python3.13/site-packages/rubicon/objc/api.py", line 339, in __call__
result = self.py_method(py_self, *args)
File "/Users/charles/toga_dev/toga/cocoa/src/toga_cocoa/widgets/canvas.py", line 41, in drawRect_
self.interface.context._draw(self.impl, draw_context=context)
File "/Users/charles/toga_dev/toga/core/src/toga/widgets/canvas.py", line 461, in _draw
obj._draw(impl, **kwargs)
File "/Users/charles/toga_dev/toga/core/src/toga/widgets/canvas.py", line 1070, in _draw
obj._draw(impl, **sub_kwargs)
File "/Users/charles/toga_dev/toga/core/src/toga/widgets/canvas.py", line 383, in _draw
impl.write_text(
File "/Users/charles/toga_dev/toga/cocoa/src/toga_cocoa/widgets/canvas.py", line 305, in write_text
rs = self._render_string(line, font, **kwargs)
File "/Users/charles/toga_dev/toga/cocoa/src/toga_cocoa/widgets/canvas.py", line 247, in _render_string
textAttributes[NSFontAttributeName] = font.native
TypeError: 'ObjCInstance' object does not support item assignment
This happens when resizing either horizontally, vertically, or both. Additionally, reducing vertical size (not necessarily smaller than initial — any reduction from current) creates weird rendering overlaps.
Notably, this doesn't happen when first rendering the window and widget. And it doesn't always happen when resizing, either, only intermittently.
Steps to reproduce
Go to the examples folder and run python -m chart
Resize the window.
Expected behavior
No exception, and proper layout/rendering
Screenshots
Environment
Operating System: macOS
Python version: 3.13
Software versions:
Toga: current main branch
Travertino: both 0.3.0 and current main branch
Logs
No response
Additional context
No response
The text was updated successfully, but these errors were encountered:
On a normal (successful) invocation, type(textAttributes) returns:
type[<ObjCMutableDictInstance: __NSDictionaryM at 0x130ada330: {}]
However, on the problem call, the same call returns:
type[<ObjCInstance: __NSDictionaryM at 0x12a2341a0: {}>]
So - it's not identifying that the MutableDict wrapper needs to be applied to the object returned by the constructor.
There's an immediate fix in converting all the use of subscript notation into setObject:forKey: calls; message passing works on any object. But that's not a very satisfying answer, as the underlying Rubicon issue still exists.
I wonder if this might be a niche manifestation of beeware/rubicon-objc#256 - if the ObjC memory address is being recycled before Python disposes of the object, that would result in the wrong object wrapper being applied, resulting in the __setitem__ handler not being available. It's only manifesting here because there are lots of calls to render strings, which means it's more likely to expose this sort of memory recycling issue.
Describe the bug
Dragging the edges of the window to resize the example app (at least on macOS) generates repeated instances of this error:
This happens when resizing either horizontally, vertically, or both. Additionally, reducing vertical size (not necessarily smaller than initial — any reduction from current) creates weird rendering overlaps.
Notably, this doesn't happen when first rendering the window and widget. And it doesn't always happen when resizing, either, only intermittently.
Steps to reproduce
python -m chart
Expected behavior
No exception, and proper layout/rendering
Screenshots
Environment
Logs
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: