Whether the wrapped C++ object of pyqt5 still exists

71 Views Asked by At

I'm working on python3 code using PyQT5.

Sometime, I have a PyQT5 object o, and I want to know whether it wraps an object which have been deleted or not. Because, otherwise, when I try to access it, I get the following error "wrapped C/C++ object of type foo has been deleted".

My goal is too close all opened window, so if the object is closed already, it's perfect. I just need to detect windows which are still opened.

I know in an ideal word, I should keep track of opened/closed windows myself, so it should not be the problem. However, I'm not allowed to change the API, and our API don't require windows to do anything when they close, so I can't keep track without breaking some add-ons using the API.

Furthermore, if the answer can use the standard library, that would be great, thus I would not have to import other library in the add-on I'm writing, and it will allow it to stay small.

0

There are 0 best solutions below