Dne 9.2.2011 23:08, Hugo Parente Lima napsal(a):
On Wednesday 09 February 2011 19:55:11 Vláďa wrote:
Dne 2.2.2011 17:21, Hugo Parente Lima napsal(a):
On Wednesday 02 February 2011 11:58:24 Vláďa wrote:
Hello,


I created a PySide application with QML UI. I have a problem with
quitting it. Sometimes it exits correctly but sometimes the Python
process hangs (the GUI disappears correctly). If I hit Ctrl+Break, I get
this error message:

QObject::killTimers: timers cannot be stopped from another thread


Do you have any idea what can be wrong in my application? It doesn't
happen always. Sometimes the program quits correctly, sometimes Python
process remains running and I have to kill it from task manager.
Could you provide some code? Without it is a hard to know if this is a
bug in PySide or in your code.
First of all let me apologize for such a late reply.

Unfortunately my code is quite huge and I can't provide a simple example
which would show the problem. But I'll try to provide at least some
parts of my code, which could be responsible for the problem.

My application is a music player. It uses MPlayer as playback backend
and has a QML UI. Python is responsible for managing library,
controlling MPlayer and the communication between backend and frontend.

MPlayer is run in a separate thread in slave mode using subprocess
module following this example:
http://code.activestate.com/recipes/440554/. I don't use any other
threads in my code (except for scanning of library). There is a timer
which checks playback status by reading and analyzing MPlayer's stdout.
I'm not sure (I have to do more tests), but the application quits
correctly if I only manage library/playlists etc., but won't start
playback. If I start playback and then close the player, Python hangs.
But I start the MPlayer subprocess always right after starting the
application, so running a subprocess shouldn't cause the problem.

The code for initializing and closing my application looks like this:

class qmlWindow(QtDeclarative.QDeclarativeView):
def __init__(self):
QtDeclarative.QDeclarativeView.__init__(self)
self.mainClass = None
def closeEvent(self, event):
self.mainClass.player.quitPlayer()

if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
view = qmlWindow()
view.setResizeMode(QtDeclarative.QDeclarativeView.SizeRootObjectToView)
rc = view.rootContext()
mainClass = Qmltopy(rc)
view.mainClass = mainClass
view.setSource('PyPlay.qml')
mainClass.rootObject = view.rootObject()
view.showMaximized()
sys.exit(app.exec_())

I subclassed the QtDeclarative.QDeclarativeView to write my own
closeEvent function (note that the described problem existed before I
did this, I tried to solve it this way). Qmltopy is the class which
holds object and functions and communicates between QML UI and playback
backend.

The mainClass.player.quitPlayer() tells MPlayer to quit. It works
correctly. If I read return code, it exists, which means the process was
ended. Also I can check in process manager that MPlayer isn't running
anymore, but python process remains there. It happens on Linux and Windows.

I don't think anyone will be able to give me a direct advice based on
this information. But I would like to get help in debugging the problem.
The problem doesn't happen always, so if I do a change and it works
correctly a couple times, I can't be sure it is solved.

According to the error I'm getting, there is a problem with stopping
some timers. Are these QML timers or Python timers (I use both)? How can
I find this out? Do I have to stop them manually before quitting my
application (I don't think so)? What should I check to know which object
wasn't correctly destroyed?
Maybe it's related to the bug 673 [1], the good news is that I fixed it today
:-).

[1]http://bugs.openbossa.org/show_bug.cgi?id=673

Thanks a lot for the information. I expect the fix will be in the next beta6 or rc1, right? I'll try it when it's released and will let you know if the problem isn't gone.

Vladimir
_______________________________________________
PySide mailing list
PySide@lists.openbossa.org
http://lists.openbossa.org/listinfo/pyside

Reply via email to