From 2b925be9704e47065b93ce852fa1dd006e9e71ce Mon Sep 17 00:00:00 2001 From: Ian Thomas Date: Fri, 9 Aug 2024 10:26:34 +0100 Subject: [PATCH] Specify argtypes when using macos msg (#1264) --- ipykernel/_eventloop_macos.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/ipykernel/_eventloop_macos.py b/ipykernel/_eventloop_macos.py index 3a6692fce..c55546fe2 100644 --- a/ipykernel/_eventloop_macos.py +++ b/ipykernel/_eventloop_macos.py @@ -17,7 +17,6 @@ objc.objc_getClass.restype = void_p objc.sel_registerName.restype = void_p objc.objc_msgSend.restype = void_p -objc.objc_msgSend.argtypes = [void_p, void_p] msg = objc.objc_msgSend @@ -80,11 +79,25 @@ def C(classname): def _NSApp(): """Return the global NSApplication instance (NSApp)""" + objc.objc_msgSend.argtypes = [void_p, void_p] return msg(C("NSApplication"), n("sharedApplication")) def _wake(NSApp): """Wake the Application""" + objc.objc_msgSend.argtypes = [ + void_p, + void_p, + void_p, + void_p, + void_p, + void_p, + void_p, + void_p, + void_p, + void_p, + void_p, + ] event = msg( C("NSEvent"), n( @@ -101,6 +114,7 @@ def _wake(NSApp): 0, # data1 0, # data2 ) + objc.objc_msgSend.argtypes = [void_p, void_p, void_p, void_p] msg(NSApp, n("postEvent:atStart:"), void_p(event), True) @@ -113,7 +127,9 @@ def stop(timer=None, loop=None): NSApp = _NSApp() # if NSApp is not running, stop CFRunLoop directly, # otherwise stop and wake NSApp + objc.objc_msgSend.argtypes = [void_p, void_p] if msg(NSApp, n("isRunning")): + objc.objc_msgSend.argtypes = [void_p, void_p, void_p] msg(NSApp, n("stop:"), NSApp) _wake(NSApp) else: @@ -148,6 +164,7 @@ def mainloop(duration=1): _triggered.clear() NSApp = _NSApp() _stop_after(duration) + objc.objc_msgSend.argtypes = [void_p, void_p] msg(NSApp, n("run")) if not _triggered.is_set(): # app closed without firing callback,