Skip to content

Commit 2b925be

Browse files
authored
Specify argtypes when using macos msg (#1264)
1 parent 1de2fb2 commit 2b925be

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

ipykernel/_eventloop_macos.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
objc.objc_getClass.restype = void_p
1818
objc.sel_registerName.restype = void_p
1919
objc.objc_msgSend.restype = void_p
20-
objc.objc_msgSend.argtypes = [void_p, void_p]
2120

2221
msg = objc.objc_msgSend
2322

@@ -80,11 +79,25 @@ def C(classname):
8079

8180
def _NSApp():
8281
"""Return the global NSApplication instance (NSApp)"""
82+
objc.objc_msgSend.argtypes = [void_p, void_p]
8383
return msg(C("NSApplication"), n("sharedApplication"))
8484

8585

8686
def _wake(NSApp):
8787
"""Wake the Application"""
88+
objc.objc_msgSend.argtypes = [
89+
void_p,
90+
void_p,
91+
void_p,
92+
void_p,
93+
void_p,
94+
void_p,
95+
void_p,
96+
void_p,
97+
void_p,
98+
void_p,
99+
void_p,
100+
]
88101
event = msg(
89102
C("NSEvent"),
90103
n(
@@ -101,6 +114,7 @@ def _wake(NSApp):
101114
0, # data1
102115
0, # data2
103116
)
117+
objc.objc_msgSend.argtypes = [void_p, void_p, void_p, void_p]
104118
msg(NSApp, n("postEvent:atStart:"), void_p(event), True)
105119

106120

@@ -113,7 +127,9 @@ def stop(timer=None, loop=None):
113127
NSApp = _NSApp()
114128
# if NSApp is not running, stop CFRunLoop directly,
115129
# otherwise stop and wake NSApp
130+
objc.objc_msgSend.argtypes = [void_p, void_p]
116131
if msg(NSApp, n("isRunning")):
132+
objc.objc_msgSend.argtypes = [void_p, void_p, void_p]
117133
msg(NSApp, n("stop:"), NSApp)
118134
_wake(NSApp)
119135
else:
@@ -148,6 +164,7 @@ def mainloop(duration=1):
148164
_triggered.clear()
149165
NSApp = _NSApp()
150166
_stop_after(duration)
167+
objc.objc_msgSend.argtypes = [void_p, void_p]
151168
msg(NSApp, n("run"))
152169
if not _triggered.is_set():
153170
# app closed without firing callback,

0 commit comments

Comments
 (0)