I can't seem to use Gtk.Builder in my gtk3+python2 install. I looked
through the examples at http://github.com/sebp/PyGObject-Tutorial.git
and everything but the builder_example.py seems to work. That example
is:
$ cat builder_example.py
from gi.repository import Gtk
class Handler:
def onDeleteWindow(self, *args):
Gtk.main_quit(*args)
def onButtonPressed(self, button):
print("Hello World!")
builder = Gtk.Builder()
builder.add_from_file("builder_example.glade")
builder.connect_signals(Handler()) # <--------- segfaults here
window = builder.get_object("window1")
window.show_all()
Gtk.main()
Running under lldb (see below) confirms that it segfaults when trying
to connect the signals. I guess that this is tricky since it'll cause
callbacks from C back into Python. Is that a known bug? Or did I do
something wrong in the build? I completely rebuilt gtk-osx from
scratch using only python2, for the record.
$ ~/.local/bin/jhbuild run lldb python builder_example.py
Current executable set to 'python' (x86_64).
(lldb) run
Process 46846 launched: '/Users/vbraun/gtk/inst/bin/python' (x86_64)
Process 46846 stopped
* thread #1: tid = 0xa4dbe3, 0x000000010161eb30, queue =
'com.apple.main-thread, stop reason = EXC_BAD_ACCESS (code=2,
address=0x10161eb30)
frame #0: 0x000000010161eb30
-> 0x10161eb30: movabsq $4302923544, %r11
0x10161eb3a: movabsq $4318161712, %r10
0x10161eb44: clc
0x10161eb45: jmpq *%r11
(lldb) up
error: unable to find CIE at 0x00000018 for cie_id = 0x00000004 for
entry at 0x00000018.
error: unable to find CIE at 0x00000050 for cie_id = 0x00000004 for
entry at 0x00000050.
frame #1: 0x00000001007965dc libffi.6.dylib`ffi_call_unix64 + 76 at
darwin64.S:75
72 leaq 176(%r10), %rsp
73
74 /* Call the user function. */
-> 75 call *%r11
76
77 /* Deallocate stack arg area; local stack frame in redzone. */
78 leaq 24(%rbp), %rsp
(lldb) up
frame #2: 0x000000010079583d
libffi.6.dylib`ffi_call(cif=0x00007fff5fbfde88, fn=0x0000000103282410,
rvalue=0x00007fff5fbfde18, avalue=0x00007fff5fbfdd60) + 1117 at
ffi64.c:492
489 }
490 }
491
-> 492 ffi_call_unix64 (stack, cif->bytes + sizeof (struct register_args),
493 cif->flags, rvalue, fn, ssecount);
494 }
495
(lldb) print fn
(void (*)()) $0 = 0x0000000103282410
(libgtk-3.0.dylib`gtk_builder_connect_signals_full at
gtkbuilder.c:1682)
(lldb) bt
* thread #1: tid = 0xa4dbe3, 0x000000010161eb30, queue =
'com.apple.main-thread, stop reason = EXC_BAD_ACCESS (code=2,
address=0x10161eb30)
frame #0: 0x000000010161eb30
frame #1: 0x00000001007965dc libffi.6.dylib`ffi_call_unix64 + 76
at darwin64.S:75
frame #2: 0x000000010079583d
libffi.6.dylib`ffi_call(cif=0x00007fff5fbfde88, fn=0x0000000103282410,
rvalue=0x00007fff5fbfde18, avalue=0x00007fff5fbfdd60) + 1117 at
ffi64.c:492
frame #3: 0x00000001004c7a7c
libgirepository-1.0.1.dylib`g_callable_info_invoke(info=0x00000001008e7940,
function=0x0000000103282410, in_args=0x0000000101640400, n_in_args=3,
out_args=0x0000000000000000, n_out_args=0,
return_value=0x00007fff5fbfe0d0, is_method=1, throws=0,
error=0x00007fff5fbfe040) + 1836 at gicallableinfo.c:680
frame #4: 0x00000001004c9fd6
libgirepository-1.0.1.dylib`g_function_info_invoke(info=0x00000001008e7940,
in_args=0x0000000101640400, n_in_args=3, out_args=0x0000000000000000,
n_out_args=0, return_value=0x00007fff5fbfe0d0,
error=0x00007fff5fbfe040) + 310 at gifunctioninfo.c:274
frame #5: 0x000000010049573e
_gi.so`_invoke_callable(state=0x00007fff5fbfe088,
cache=0x0000000102814300, callable_info=0x00000001008e7940,
function_ptr=0x0000000000000000) + 398 at pygi-invoke.c:64
frame #6: 0x0000000100494c3a
_gi.so`pygi_callable_info_invoke(info=0x00000001008e7940,
py_args=0x00000001015aa960, kwargs=0x0000000000000000,
cache=0x0000000102814300, function_ptr=0x0000000000000000,
user_data=0x0000000000000000) + 202 at pygi-invoke.c:652
frame #7: 0x0000000100495e51
_gi.so`_wrap_g_callable_info_invoke(self=0x00000001031bf7d8,
py_args=0x00000001015aa960, kwargs=0x0000000000000000) + 145 at
pygi-invoke.c:675
frame #8: 0x0000000100484fc9
_gi.so`_callable_info_call(self=0x00000001015b7570,
args=0x0000000101537440, kwargs=0x0000000000000000) + 281 at
pygi-info.c:428
frame #9: 0x00000001004853de
_gi.so`_function_info_call(self=0x00000001015b7570,
args=0x0000000101537440, kwargs=0x0000000000000000) + 590 at
pygi-info.c:494
frame #10: 0x0000000100012765
libpython2.7.dylib`PyObject_Call(func=<unavailable>,
arg=<unavailable>, kw=0x0000000000000000) + 101 at abstract.c:2529
frame #11: 0x00000001000a5fc4
libpython2.7.dylib`PyEval_EvalFrameEx [inlined]
do_call(pp_stack=0x000000010161dfb0, nk=<unavailable>,
func=<unavailable>) + 14 at ceval.c:4239
frame #12: 0x00000001000a5fb6
libpython2.7.dylib`PyEval_EvalFrameEx [inlined]
call_function(pp_stack=0x000000010161dfb0) at ceval.c:4044
frame #13: 0x00000001000a5fb6
libpython2.7.dylib`PyEval_EvalFrameEx(f=0x000000010161de10,
throwflag=<unavailable>) + 16054 at ceval.c:2666
frame #14: 0x00000001000a1f86
libpython2.7.dylib`PyEval_EvalCodeEx(co=<unavailable>,
globals=<unavailable>, locals=<unavailable>, args=0x0000000100000002,
argcount=<unavailable>, kws=0x0000000100375268, kwcount=<unavailable>,
defs=<unavailable>, defcount=<unavailable>, closure=<unavailable>) +
1734 at ceval.c:3253
frame #15: 0x00000001000a8e46
libpython2.7.dylib`fast_function(func=<unavailable>,
pp_stack=<unavailable>, n=<unavailable>, na=<unavailable>,
nk=<unavailable>) + 294 at ceval.c:4117
frame #16: 0x00000001000a519b
libpython2.7.dylib`PyEval_EvalFrameEx [inlined]
call_function(pp_stack=0x0000000100375268) + 95 at ceval.c:4042
frame #17: 0x00000001000a513c
libpython2.7.dylib`PyEval_EvalFrameEx(f=0x00000001003750e0,
throwflag=<unavailable>) + 12348 at ceval.c:2666
frame #18: 0x00000001000a1f86
libpython2.7.dylib`PyEval_EvalCodeEx(co=<unavailable>,
globals=<unavailable>, locals=<unavailable>, args=0x0000000000000000,
argcount=<unavailable>, kws=0x0000000000000000, kwcount=<unavailable>,
defs=<unavailable>, defcount=<unavailable>, closure=<unavailable>) +
1734 at ceval.c:3253
frame #19: 0x00000001000a18b6
libpython2.7.dylib`PyEval_EvalCode(co=<unavailable>,
globals=<unavailable>, locals=<unavailable>) + 54 at ceval.c:667
frame #20: 0x00000001000c9471 libpython2.7.dylib`PyRun_FileExFlags
[inlined] run_mod(arena=<unavailable>, mod=<unavailable>,
flags=<unavailable>, filename=<unavailable>,
locals=0x000000010031aac0, globals=0x000000010031aac0) + 44 at
pythonrun.c:1353
frame #21: 0x00000001000c9445
libpython2.7.dylib`PyRun_FileExFlags(fp=<unavailable>,
filename=<unavailable>, start=<unavailable>,
globals=0x000000010031aac0, locals=0x000000010031aac0, closeit=1,
flags=<unavailable>) + 117 at pythonrun.c:1339
frame #22: 0x00000001000c8fca
libpython2.7.dylib`PyRun_SimpleFileExFlags(fp=0x00007fff7b099280,
filename=0x00007fff5fbfeb6f, closeit=1, flags=0x00007fff5fbfe880) +
698 at pythonrun.c:943
frame #23: 0x00000001000dcd6a
libpython2.7.dylib`Py_Main(argc=<unavailable>,
argv=0x00007fff5fbfe8d0) + 3306 at main.c:639
frame #24: 0x0000000100001f24 python`start + 52