Skip to content

Commit b1d721b

Browse files
committed
Try to fix bool(wxWindow)
1 parent d842eb8 commit b1d721b

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

cffi/wrapper_lib/cppwrapper.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,9 @@ def forget_ptr(ptr):
340340
_detach_children(obj)
341341
# TODO: does obj need to detach from its parent too?
342342

343+
def is_alive(obj):
344+
return bool(obj._cpp_obj)
345+
343346
def take_ownership(obj):
344347
if obj is None:
345348
return

etg/window.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,14 @@ def run():
158158
#endif
159159
""")
160160

161+
# TODO(amauryfa): platform-independent version?
161162
c.addPyMethod('__nonzero__', '(self)',
162163
doc="Can be used to test if the C++ part of the window still exists, with \n"
163164
"code like this::\n\n"
164165
" if theWindow:\n"
165166
" doSomething()",
166167
body="""\
167-
import wx.siplib
168-
return not wx.siplib.isdeleted(self)
168+
return wrapper_lib.is_alive(self)
169169
""")
170170
c.addPyCode('Window.__bool__ = Window.__nonzero__') # For Python 3
171171

0 commit comments

Comments
 (0)