Hacker News new | past | comments | ask | show | jobs | submit login

I've always found Qt and Python (PyQt and PySide) to be a weird match. So many times did I end up with cryptic segfaults in the python VM due to some python object being collected "too early", creating a dangling pointer in the C++ world. This can happen if you forget to set the parent object, for instance.

I know that those are things you have to worry about when you write C++, but when in the python world, you kind of expect everything to be refcounted for you. If I ever have to write a GUI app in python again, I'll probably chose another framework.




This just means that wrapper around C(++) code doesn't handle resources correctly. As you said, once inside Python you shouldn't care about object collection process. Nothing should lead to segfaults, in worst case you should get an exception about missing parent ref.


more exactly “underlying C/C++ object has been deleted" error.


In my experience, those errors are easy to resolve: just assign the new object to something, so it isn't immediately deleted. A little awkward, maybe, and it shouldn't happen, but if that's the worst quirk of PyQT/PySide, I can deal.


Those errors are always related with a bad implementation where there is something holding a reference to the qt python object represented by the bidding therefore keeping it alive even when their c++ instance has been already deleted. The solution is to go back to the drawing board and improve the implementation :)




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: