Skip to content

Commit 6f5f719

Browse files
committed
Fix GC unable to resolve Controller events
1 parent 52af22d commit 6f5f719

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

gtk/src/toga_gtk/widgets/textinput.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from travertino.size import at_least
22

3+
from toga.handlers import WeakrefCallable
34
from toga.keys import Key
45
from toga_gtk.keys import toga_key
56

@@ -22,12 +23,18 @@ def create(self):
2223
self.focus_controller = Gtk.EventControllerFocus.new()
2324
self.native.add_controller(self.focus_controller)
2425

25-
self.focus_controller.connect("enter", self.gtk_focus_in_event)
26-
self.focus_controller.connect("leave", self.gtk_focus_out_event)
26+
self.focus_controller.connect(
27+
"enter", WeakrefCallable(self.gtk_focus_in_event)
28+
)
29+
self.focus_controller.connect(
30+
"leave", WeakrefCallable(self.gtk_focus_out_event)
31+
)
2732

2833
self.key_controller = Gtk.EventControllerKey.new()
2934
self.native.add_controller(self.key_controller)
30-
self.key_controller.connect("key-pressed", self.gtk_key_pressed)
35+
self.key_controller.connect(
36+
"key-pressed", WeakrefCallable(self.gtk_key_pressed)
37+
)
3138

3239
def gtk_on_change(self, *_args):
3340
self.interface._value_changed()

testbed/tests/widgets/test_passwordinput.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ def verify_font_sizes():
4545
return False, True
4646

4747

48-
test_cleanup = build_cleanup_test(
49-
toga.PasswordInput, xfail_platforms=("android", "linux")
50-
)
48+
test_cleanup = build_cleanup_test(toga.PasswordInput, xfail_platforms=("android",))
5149

5250

5351
async def test_value_hidden(widget, probe):

testbed/tests/widgets/test_textinput.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async def placeholder(request, widget):
5252
widget.placeholder = request.param
5353

5454

55-
test_cleanup = build_cleanup_test(toga.TextInput, xfail_platforms=("android", "linux"))
55+
test_cleanup = build_cleanup_test(toga.TextInput, xfail_platforms=("android",))
5656

5757

5858
async def test_value_not_hidden(widget, probe):

0 commit comments

Comments
 (0)