Closed mrzv closed 4 years ago
This is clearly a bug. The code invoked by on_closing
is executed in a separate thread and is invoked after window is already closed.
I think this can be resolved with an additional lock just to handle the closing case.
Good to know. Thanks for looking into it. I wasn't sure if I was misunderstanding something, or if it was a bug.
Is there a good way to save the window shape on closing until this is fixed, or am I better off just waiting?
I will try to fix this asap. Meanwhile the best course solution would be periodically save window dimensions somewhere and read the final value on window closing. Stupid, but it should work.
@mrzv
I pushed a fix for Cocoa to the closing-fix
branch. Window dimensions and position should be accessible during window.closing
event. Invoking other methods might still result in a deadlock though.
Other platforms are not checked yet
Thanks!
I should probably mention that I had the same deadlock, when I tried to read the shape of the window from window.closed
. I don't know if it's relevant and the PR fixes both cases, but just FYI.
c0ba525 fixed window.closing
event, but not window.closed
. That one still causes a deadlock.
Getting window properties on window.closed doesn’t make any sense, as the window does not longer exist. It should not cause a deadlock though.
Specification
Description
I'm new to pywebview, and I'm trying to figure out the right way to do the following. I'd like to save the shape of the window (width and height), when the window is closed or closing. The problem is that when I try to do this from a callback (added to
window.closing
), everything hangs. I think there is a deadlock somewhere, but I don't quite understand the design.What's the right way to do this?
I can access width and height from the function
f
I pass towebview.start(f, window)
, but that doesn't solve the issue of how to trigger this logic when the window is closing.