Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to call completion handlers? #255

Closed
ronaldoussoren opened this issue Nov 18, 2018 · 8 comments
Closed

How to call completion handlers? #255

ronaldoussoren opened this issue Nov 18, 2018 · 8 comments

Comments

@ronaldoussoren
Copy link
Owner

Original report by Roman Sí (Bitbucket: lokilaufey, GitHub: lokilaufey).


Consider def webView_runJavaScriptAlertPanelWithMessage_initiatedByFrame_completionHandler_(self, webview, message, frame, completion_handler) from https://developer.apple.com/documentation/webkit/wkuidelegate

Calling completion_handler() as is results in a {TypeError}cannot call block without a signature. What is a proper way to call this handler?

@ronaldoussoren
Copy link
Owner Author

Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren).


The code that you wrote should have worked without problems, but for some reason doesn't. I've checked PyObjC's metadata and that looks sane in the current trunk (that will at some time be 5.1.2) and there haven't been updates to the WebKit metadata since the 5.1 release.

What version of PyObjC do you use?

And do you have an example script that demonstrates the problem?

P.S. Sorry about the slow response, I've been traveling and didn't have access to my computer.

@ronaldoussoren
Copy link
Owner Author

Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren).


I think I can reproduce the root issue in a test case.

I think the completion handler that the framework passes to Python does not have ObjC runtime metadata that describes its interface, and PyObjC does not use its metadata system to add the correct metadata.

I'm working on a patch.

@ronaldoussoren
Copy link
Owner Author

Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren).


This should be fixed in changeset df9ed14ba3a0

Installing pyobjc-core from the repository should be enough to confirm.

I intent tot release PyObC 5.1.2 this weekend with a number of bug fixes, including this one.

@ronaldoussoren
Copy link
Owner Author

Original comment by Roman Sí (Bitbucket: lokilaufey, GitHub: lokilaufey).


Sorry for the late response. We managed to fix the issue locally with this commit r0x0r/pywebview@f3f9cc0

Glad to hear that the issue is addressed and thanks for your work!

@ronaldoussoren
Copy link
Owner Author

Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren).


The fix in the pywebview repository messes with PyObjC internals and as such is fragile.

Sadly enough I don't have a better workaround, unless you can require PyObjC 5.1.2 or later.

@ronaldoussoren
Copy link
Owner Author

Original comment by Roman Sí (Bitbucket: lokilaufey, GitHub: lokilaufey).


Would it be beneficial to check for the PyObjC version and apply it only the version is <5.1.2?

@ronaldoussoren
Copy link
Owner Author

Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren).


I'd just require PyObjC 5.1.2 or later. Updating is easy there days, the only ones stuck with an old version of PyObjC are users that want to use the version of PyObjC that ships with macOS.

@ronaldoussoren
Copy link
Owner Author

Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren).


Fixed in changeset df9ed14ba3a0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant