I have a PySide application that hosts a VLC MediaPlayer instance within a QWidget. When the application is closed via the QMainWindow's close event, or by using QApplication.quit(), the UI disappears and then I get a Windows dialog "python.exe has stopped working".
The QApplication hosts a custom QMainWindow class, which contains a custom QWidget (which handles all the UI tasks, with QMainWindow handling messaging between threads - the app records keystrokes and writes output files in background threads). There is also a timer running the the main QWidget that updates a LineEdit with the current position in the video.
The crash happens whether files are being written or not (code commented out).
Do I need to be performing some type of garbage collection, or perhaps disposing of my objects in a specific order? I've tried stopping the timer, setting the MediaPlayer, the Instance, and the frame that hosts the MediaPlayer all to None, and then detroying the frame (self.videoFrame.destroy()), but the app still crashes.
The basic code was based on the example Qt application from vlc's repo example, which has no special garbage collection or disposal of objects.
I'm running Python 2.6 on Windows XP. Right now I run Python straight from the command line, but have it set up to create an exe with Py2Exe once I get this crash fixed.
Wrapping in function helped me
I know this is late, but I did find a solution. In my case there was no memory leaks, but some of the QObjects must not have been closing properly. Python 3, PySide 1.2.1
This will loop through everything that is in the main window, and it will close and delete all of the items found if possible. It made my application close immediately with no memory leaks or problems. You may also have to specifically close some items and make sure that no errors are caused from trying to delete an item that was already deleted.
EDIT
I eventually got rid of all the above clean up code with an event filter that called
QtGui.qApp.closeAllWindows()
. However, later the issue came up again. I now believe it has something to do with the C++ and python objects getting out of sync and how the objects are cleaned up.This seemed to work better for me. I also have my application and window wrapped in a function.