Skip to content

Commit

Permalink
fixed: Python threads should be allowed to run while waiting for dial…
Browse files Browse the repository at this point in the history
…ogs to complete. Fixes xbmc#9947.

(cherry picked from commit b2b756599f6ae242a4b640ce020e01a3a892488d)

git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/branches/Dharma@33236 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
  • Loading branch information
jmarshallnz committed Aug 28, 2010
1 parent bd412e1 commit 75db083
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
9 changes: 3 additions & 6 deletions xbmc/lib/libPython/xbmcmodule/dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ namespace PYXBMC
pDialog->SetLine(2, utf8Line[3]);

//send message and wait for user input
ThreadMessage tMsg = {TMSG_DIALOG_DOMODAL, window, ACTIVE_WINDOW};
g_application.getApplicationMessenger().SendMessage(tMsg, true);
PyXBMCWaitForThreadMessage(TMSG_DIALOG_DOMODAL, window, ACTIVE_WINDOW);

return Py_BuildValue((char*)"b", pDialog->IsConfirmed());
}
Expand Down Expand Up @@ -327,8 +326,7 @@ namespace PYXBMC
pDialog->SetChoice(1,utf8Line[5]);

//send message and wait for user input
ThreadMessage tMsg = {TMSG_DIALOG_DOMODAL, window, ACTIVE_WINDOW};
g_application.getApplicationMessenger().SendMessage(tMsg, true);
PyXBMCWaitForThreadMessage(TMSG_DIALOG_DOMODAL, window, ACTIVE_WINDOW);

return Py_BuildValue((char*)"b", pDialog->IsConfirmed());
}
Expand Down Expand Up @@ -376,8 +374,7 @@ namespace PYXBMC
pDialog->SetAutoClose(autoClose);

//send message and wait for user input
ThreadMessage tMsg = {TMSG_DIALOG_DOMODAL, window, ACTIVE_WINDOW};
g_application.getApplicationMessenger().SendMessage(tMsg, true);
PyXBMCWaitForThreadMessage(TMSG_DIALOG_DOMODAL, window, ACTIVE_WINDOW);

return Py_BuildValue((char*)"i", pDialog->GetSelectedLabel());
}
Expand Down
3 changes: 1 addition & 2 deletions xbmc/lib/libPython/xbmcmodule/keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ namespace PYXBMC
pKeyboard->SetAutoClose(autoClose);

// do modal of dialog
ThreadMessage tMsg = {TMSG_DIALOG_DOMODAL, WINDOW_DIALOG_KEYBOARD, g_windowManager.GetActiveWindow()};
g_application.getApplicationMessenger().SendMessage(tMsg, true);
PyXBMCWaitForThreadMessage(TMSG_DIALOG_DOMODAL, WINDOW_DIALOG_KEYBOARD, g_windowManager.GetActiveWindow());

Py_INCREF(Py_None);
return Py_None;
Expand Down
9 changes: 9 additions & 0 deletions xbmc/lib/libPython/xbmcmodule/pyutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "utils/CharsetConverter.h"
#include "CriticalSection.h"
#include "SingleLock.h"
#include "Application.h"

using namespace std;

Expand Down Expand Up @@ -91,6 +92,14 @@ namespace PYXBMC
}
}

void PyXBMCWaitForThreadMessage(int message, int param1, int param2)
{
Py_BEGIN_ALLOW_THREADS
ThreadMessage tMsg = {message, param1, param2};
g_application.getApplicationMessenger().SendMessage(tMsg, true);
Py_END_ALLOW_THREADS
}

static char defaultImage[1024];
/*
* Looks in references.xml for image name
Expand Down
1 change: 1 addition & 0 deletions xbmc/lib/libPython/xbmcmodule/pyutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ namespace PYXBMC
bool PyXBMCWindowIsNull(void* pWindow);

void PyXBMCInitializeTypeObject(PyTypeObject* type_object);
void PyXBMCWaitForThreadMessage(int message, int param1, int param2);
}

// Python doesn't play nice with PyXBMC_AddPendingCall
Expand Down

0 comments on commit 75db083

Please sign in to comment.