Permalink
Browse files

[fix] This allows the Monitor to receive onScreensaverDeactivated cal…

…lbacks while in DoModal. This may have further reaching effects sicne it effecively allows the DoModal call to repeatedly invoke makePendingCalls avoiding the need for extraneous PulseActionEvent calls.
  • Loading branch information...
1 parent 882b06c commit 33c04d0d5d8fd89c77708da6f5af25bc5a4b73b1 Jim Carroll committed Nov 11, 2012
@@ -117,7 +117,7 @@ namespace XBMCAddon
virtual void unregisterPlayerCallback(IPlayerCallback* player) = 0;
virtual void registerMonitorCallback(XBMCAddon::xbmc::Monitor* player) = 0;
virtual void unregisterMonitorCallback(XBMCAddon::xbmc::Monitor* player) = 0;
- virtual void waitForEvent(CEvent& hEvent) = 0;
+ virtual bool waitForEvent(CEvent& hEvent, unsigned int milliseconds) = 0;
static void setLanguageHook(LanguageHook* languageHook);
static LanguageHook* getLanguageHook();
@@ -371,13 +371,13 @@ namespace XBMCAddon
m_actionEvent.Set();
}
- void Window::WaitForActionEvent()
+ bool Window::WaitForActionEvent(unsigned int milliseconds)
{
TRACE;
// DO NOT MAKE THIS A DELAYED CALL!!!!
- if (languageHook)
- languageHook->waitForEvent(m_actionEvent);
+ bool ret = languageHook == NULL ? m_actionEvent.WaitMSec(milliseconds) : languageHook->waitForEvent(m_actionEvent,milliseconds);
m_actionEvent.Reset();
+ return ret;
}
bool Window::OnAction(const CAction &action)
@@ -672,10 +672,16 @@ namespace XBMCAddon
// break;
// }
languageHook->makePendingCalls(); // MakePendingCalls
+
+ bool stillWaiting;
+ do
{
- DelayedCallGuard dcguard(languageHook);
- WaitForActionEvent();
- }
+ {
+ DelayedCallGuard dcguard(languageHook);
+ stillWaiting = WaitForActionEvent(10) ? false : true;
+ }
+ languageHook->makePendingCalls();
+ } while (stillWaiting);
}
}
}
@@ -126,7 +126,7 @@ namespace XBMCAddon
Control* GetControlById(int iControlId) throw (WindowException);
SWIGHIDDENVIRTUAL void PulseActionEvent();
- SWIGHIDDENVIRTUAL void WaitForActionEvent();
+ SWIGHIDDENVIRTUAL bool WaitForActionEvent(unsigned int milliseconds);
#endif
public:
@@ -174,15 +174,10 @@ namespace XBMCAddon
void LanguageHook::unregisterPlayerCallback(IPlayerCallback* player) { g_pythonParser.UnregisterPythonPlayerCallBack(player); }
void LanguageHook::registerMonitorCallback(XBMCAddon::xbmc::Monitor* monitor) { g_pythonParser.RegisterPythonMonitorCallBack(monitor); }
void LanguageHook::unregisterMonitorCallback(XBMCAddon::xbmc::Monitor* monitor) { g_pythonParser.UnregisterPythonMonitorCallBack(monitor); }
- void LanguageHook::waitForEvent(CEvent& hEvent) { g_pythonParser.WaitForEvent(hEvent); }
-
-// void LanguageHook::constructing(AddonClass* beingConstructed)
-// {
-// }
-//
-// void LanguageHook::destructing(AddonClass* beingDestructed)
-// {
-// }
+ bool LanguageHook::waitForEvent(CEvent& hEvent, unsigned int milliseconds)
+ {
+ return g_pythonParser.WaitForEvent(hEvent,milliseconds);
+ }
}
}
@@ -78,7 +78,7 @@ namespace XBMCAddon
virtual void unregisterPlayerCallback(IPlayerCallback* player);
virtual void registerMonitorCallback(XBMCAddon::xbmc::Monitor* monitor);
virtual void unregisterMonitorCallback(XBMCAddon::xbmc::Monitor* monitor);
- virtual void waitForEvent(CEvent& hEvent);
+ virtual bool waitForEvent(CEvent& hEvent, unsigned int milliseconds);
static LanguageHook* getInstance();
};
@@ -863,12 +863,14 @@ void XBPython::PulseGlobalEvent()
m_globalEvent.Set();
}
-void XBPython::WaitForEvent(CEvent& hEvent)
+bool XBPython::WaitForEvent(CEvent& hEvent, unsigned int milliseconds)
{
// wait for either this event our our global event
XbmcThreads::CEventGroup eventGroup(&hEvent, &m_globalEvent, NULL);
- eventGroup.wait();
- m_globalEvent.Reset();
+ CEvent* ret = eventGroup.wait(milliseconds);
+ if (ret)
+ m_globalEvent.Reset();
+ return ret == NULL ? false : true;
}
// execute script, returns -1 if script doesn't exist
@@ -85,7 +85,7 @@ class XBPython :
void Process();
void PulseGlobalEvent();
- void WaitForEvent(CEvent& hEvent);
+ bool WaitForEvent(CEvent& hEvent, unsigned int milliseconds);
int ScriptsSize();
int GetPythonScriptId(int scriptPosition);

0 comments on commit 33c04d0

Please sign in to comment.