Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed poor synchronization in XBPyThread::stop() #1221

Merged
1 commit merged into from Aug 4, 2012

Conversation

garbear
Copy link
Member

@garbear garbear commented Jul 26, 2012

This fixes XBPyThread::stop() waiting on a event in the application thread, which precludes the event from getting triggered if a Python script relies on the messaging system to close itself (such as calling the .close() function on an open dialog)

An alternative could be not ever calling ::stop() in the app thread. I don't know how feasible this is.

My strategy for handling messages comes from
https://github.com/xbmc/xbmc/blob/master/xbmc/cores/dvdplayer/DVDPlayer.cpp#L461
https://github.com/xbmc/xbmc/blob/master/xbmc/filesystem/Directory.cpp#L170
https://github.com/xbmc/xbmc/blob/master/xbmc/guilib/GUIDialog.cpp#L176

and I've learned that just because it's done throughout the code base doesn't make it correct, consistent or complete. Always open to being pointed in the right direction :)

@@ -442,10 +445,27 @@ void XBPyThread::stop()
PyThreadState_Swap(old);
PyEval_ReleaseLock();

if(!stoppedEvent.WaitMSec(5000))//let the script 5 secs for shut stuff down
unsigned int checkpoint = XbmcThreads::SystemClockMillis();

This comment was marked as spam.

@elupus
Copy link
Contributor

elupus commented Jul 26, 2012

With above two changes, it should be a good fix.

@garbear
Copy link
Member Author

garbear commented Jul 26, 2012

Fixed elupus's comment. What value should be used for WaitMSec(15)? I chose 15 because it's about 60fps.

@elupus
Copy link
Contributor

elupus commented Jul 26, 2012

Should be fine.

// dismantle themselves. Python dialogs aren't normal XBMC dialogs, they rely
// on TMSG_GUI_PYTHON_DIALOG messages, so pump the render loop.
CSingleLock lock(g_graphicsContext);
g_windowManager.ProcessRenderLoop();

This comment was marked as spam.

This comment was marked as spam.

@garbear
Copy link
Member Author

garbear commented Jul 27, 2012

Updated the message processing part (see commit description)

@garbear
Copy link
Member Author

garbear commented Jul 31, 2012

Rebased into single commit. @elupus any more thoughts?

This fixes XBPyThread::stop() waiting on a event in the application thread, which precludes the event from getting triggered if a Python script relies on the messaging system to close itself (such as calling the .close() function on an open dialog)
ghost pushed a commit that referenced this pull request Aug 4, 2012
Fixed poor synchronization in XBPyThread::stop()
@ghost ghost merged commit f7a6e2b into xbmc:master Aug 4, 2012
tru pushed a commit to plexinc/plex-home-theater-public that referenced this pull request Jun 13, 2014
Currently we only add the main language code with two letters: en, sv
etc.

Fixes xbmc#1221
tru pushed a commit to RasPlex/plex-home-theatre that referenced this pull request Aug 21, 2014
Currently we only add the main language code with two letters: en, sv
etc.

Fixes xbmc#1221
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants