#include "object.h"
#include <stdio.h>
+#include <string.h>
#include <lib/python/swig.h>
inline void ptrAssert(void *p) { if (!p) *(unsigned long*)0=0; }
{
protected:
T *ptr;
+ char m_ptrStr[sizeof(void*)*2+1];
+ void updatePtrStr()
+ {
+ if (ptr) {
+ if (sizeof(void*) > 4)
+ sprintf(m_ptrStr, "%llx", (unsigned long long)ptr);
+ else
+ sprintf(m_ptrStr, "%lx", (unsigned long)ptr);
+ }
+ else
+ strcpy(m_ptrStr, "NIL");
+ }
public:
T &operator*() { return *ptr; }
ePtr(): ptr(0)
{
if (c)
c->AddRef();
+ updatePtrStr();
}
- ePtr(const ePtr &c)
+ ePtr(const ePtr &c): ptr(c.ptr)
{
- ptr=c.ptr;
if (ptr)
ptr->AddRef();
+ updatePtrStr();
}
ePtr &operator=(T *c)
{
if (ptr)
ptr->Release();
ptr=c;
+ updatePtrStr();
return *this;
}
-
ePtr &operator=(ePtr<T> &c)
{
if (c.ptr)
if (ptr)
ptr->Release();
ptr=c.ptr;
+ updatePtrStr();
return *this;
}
-
~ePtr()
{
if (ptr)
ptr->Release();
}
-
+ char *getPtrString()
+ {
+ return m_ptrStr;
+ }
#ifndef SWIG
T* grabRef() { if (!ptr) return 0; ptr->AddRef(); return ptr; }
T* &ptrref() { ASSERT(!ptr); return ptr; }
ptr=c;
return *this;
}
-
eUsePtr &operator=(eUsePtr<T> &c)
{
if (c.ptr)
ptr=c.ptr;
return *this;
}
-
~eUsePtr()
{
if (ptr)
ptr->Release();
}
}
-
#ifndef SWIG
T* grabRef() { if (!ptr) return 0; ptr->AddRef(); ptr->AddUse(); return ptr; }
T* &ptrref() { ASSERT(!ptr); return ptr; }
eMutablePtr(): ePtr<T>(0)
{
}
-
eMutablePtr(T *c): ePtr<T>(c)
{
}
-
eMutablePtr(const eMutablePtr &c): ePtr<T>(c)
{
}
-
eMutablePtr &operator=(T *c)
{
ePtr<T>::operator=(c);
return *this;
}
-
-
ePtrHelper<T> operator->() { ptrAssert(ptr); return ePtrHelper<T>(ptr); }
-
/* for const objects, we don't need the helper, as they can't */
/* be changed outside the program flow. at least this is */
/* what the compiler assumes, so in case you're using const */
"""Tracks service events into a screen"""
InfoBarStack = [ ]
InfoBarStackSize = 0
- oldService = None
+ oldServiceStr = None
EventMap = { }
navcore = None
if func_list:
nav = set.navcore
cur_ref = nav.getCurrentlyPlayingServiceReference()
- old_service_running = set.oldRef and cur_ref and cur_ref == set.oldRef and set.oldService and set.oldService == str(nav.getCurrentService())
-# print "old_service_running", old_service_running
- if not old_service_running and set.oldService:
- set.oldService = None
+ old_service_running = set.oldRef and cur_ref and cur_ref == set.oldRef and set.oldServiceStr == nav.getCurrentService().getPtrString()
+ if not old_service_running and set.oldServiceStr:
+ set.oldServiceStr = None
set.oldRef = None
ssize = set.InfoBarStackSize
stack = set.InfoBarStack
(not old_service_running and stack[ssize-1] == func[1]) or # let pass events from currently running service just to current active screen (derived from InfoBarBase)
(old_service_running and ssize > 1 and stack[ssize-2] == func[1])): # let pass events from old running service just to previous active screen (derived from InfoBarBase)
func[2]()
-# else:
-# print "ignore event", ev, "for inactive infobar '" + str(self.screen) + "'"
@staticmethod
def setActiveInfoBar(infobar, old_service, old_ref):
set = ServiceEventTracker
set.oldRef = old_ref
- set.oldService = old_service and str(old_service)
+ set.oldServiceStr = old_service and old_service.getPtrString()
assert infobar not in set.InfoBarStack, "FATAL: Infobar '" + str(infobar) + "' is already active!"
set.InfoBarStack.append(infobar)
set.InfoBarStackSize += 1
set = ServiceEventTracker
stack = set.InfoBarStack
if set.InfoBarStackSize:
+ nav = set.navcore
set.InfoBarStackSize -= 1
del stack[set.InfoBarStackSize]
+ old_service = nav.getCurrentService()
+ set.oldServiceStr = old_service and old_service.getPtrString()
+ set.oldRef = nav.getCurrentlyPlayingServiceReference()
# if set.InfoBarStackSize:
# print "ServiceEventTracker reset active '" + str(stack[set.InfoBarStackSize-1]) + "'"