Returning bool from GUIWinow.OnAction
#1
Question 
I noticed that the thumbsticks are difficult to use in python since they also key for the seekbar / volume bar so am trying to find a solution to this.

Looking at the code if True is returned from OnAction I think the action is consumed/used up. Is that right?

If so the problem then is here:
http://xbmc.svn.sourceforge.net/viewvc/x...arkup#l_24
Code:
24 bool CGUIPythonWindow::OnAction(const CAction &action)
   25 {
   26   // do the base class window first, and the call to python after this
   27     bool ret = CGUIWindow::OnAction(action);
   28     if(pCallbackWindow)
   29     {
   30         PyXBMCAction* inf = new PyXBMCAction;
   31         inf->pObject = Action_FromAction(action);
   32         inf->pCallbackWindow = pCallbackWindow;
   33
   34         // aquire lock?
   35         Py_AddPendingCall(Py_XBMC_Event_OnAction, inf);
   36         PulseActionEvent();
   37     }
   38   return ret;
   39 }

As you can see it calls the base window first which im guessing is what will bring up the seekbars or whatever. Ideally I'd like for the python xbmcgui.Window.onAction method to return the bool. I can get that in the Py_XBMC_Event_OnAction method but a problem I think with that is that the python module is on a different thread than the main gui ?

I know there is a Py_MakePendingCalls which consumes the Py_AddPendingCalls but that shouldnt be called from the main thread? Basically this threading seems to only allow one way communication... as in you cant send arguments to python and get the return value at one time...

A solution I have is to add a field to the py Window Object like setConsumeActions(bool) which will cause OnAction to always return true. Is there a major problem with this? Can anyone think of a better way? Is it bad to call PyObject_CallMethod in the main thread?

Lotta questions here and would like to know if I am following the right track...
Reply
#2
Hi there,

Actually, the seekbar/volume stuff is handled in CApplication::OnAction(), so you'll have to check there first, but I'm pretty sure that if the window OnAction() returns true (action is consumed) then the global stuff in CApplication::OnAction() doesn't get executed.

So yes, you are most definitely on the right track. Now, as for events etc. from python, what does PulseActionEvent() do exactly? (I don't have the code in front of me, but I suspect that that in fact requests that the action is performed by the python thread). If so, and if it waits for return (quite probably not) then the solution is straightforward. If not, then a setConsumeActions() type thing would do the trick.

I'll try and contact darkie for his thoughts.

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#3
Code:
void CGUIPythonWindow::PulseActionEvent()
{
    SetEvent(m_actionEvent);
}
I couldnt find where SetEvent is for some reason... I think that is some weird dll thing? The event didnt seem to have real information
Code:
m_actionEvent = CreateEvent(NULL, true, false, NULL);
so I figure it tells XBMC to redraw or something...
If the threading model is like that than I guess there is no clean solution short of some thread synchronization... ohh well.
Reply

Logout Mark Read Team Forum Stats Members Help
Returning bool from GUIWinow.OnAction0