Added test for events pending for windows already disposed. These events are removed from the event stack now.
Maarten
This commit is contained in:
@@ -66,7 +66,7 @@ GHOST_TUns32 GHOST_EventManager::getNumEvents()
|
||||
GHOST_TUns32 GHOST_EventManager::getNumEvents(GHOST_TEventType type)
|
||||
{
|
||||
GHOST_TUns32 numEvents = 0;
|
||||
std::deque<GHOST_IEvent*>::iterator p;
|
||||
TEventStack::iterator p;
|
||||
for (p = m_events.begin(); p != m_events.end(); p++) {
|
||||
if ((*p)->getType() == type) {
|
||||
numEvents++;
|
||||
@@ -106,13 +106,6 @@ bool GHOST_EventManager::dispatchEvent(GHOST_IEvent* event)
|
||||
bool handled;
|
||||
if (event) {
|
||||
handled = true;
|
||||
/*
|
||||
for (unsigned int i = 0; i < m_consumers.size(); i++) {
|
||||
if (m_consumers[i]->processEvent(event)) {
|
||||
handled = false;
|
||||
}
|
||||
}
|
||||
*/
|
||||
TConsumerVector::iterator iter;
|
||||
for (iter = m_consumers.begin(); iter != m_consumers.end(); iter++) {
|
||||
if ((*iter)->processEvent(event)) {
|
||||
@@ -197,6 +190,57 @@ GHOST_TSuccess GHOST_EventManager::removeConsumer(GHOST_IEventConsumer* consumer
|
||||
}
|
||||
|
||||
|
||||
void GHOST_EventManager::removeWindowEvents(GHOST_IWindow* window)
|
||||
{
|
||||
TEventStack::iterator iter;
|
||||
iter = m_events.begin();
|
||||
while (iter != m_events.end())
|
||||
{
|
||||
GHOST_IEvent* event = *iter;
|
||||
if (event->getWindow() == window)
|
||||
{
|
||||
GHOST_PRINT("GHOST_EventManager::removeWindowEvents(): removing event\n");
|
||||
/*
|
||||
* Found an event for this window, remove it.
|
||||
* The iterator will become invalid.
|
||||
*/
|
||||
delete event;
|
||||
m_events.erase(iter);
|
||||
iter = m_events.begin();
|
||||
}
|
||||
else
|
||||
{
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GHOST_EventManager::removeTypeEvents(GHOST_TEventType type, GHOST_IWindow* window)
|
||||
{
|
||||
TEventStack::iterator iter;
|
||||
iter = m_events.begin();
|
||||
while (iter != m_events.end())
|
||||
{
|
||||
GHOST_IEvent* event = *iter;
|
||||
if ((event->getType() == type) && (!window || (event->getWindow() == window)))
|
||||
{
|
||||
GHOST_PRINT("GHOST_EventManager::removeTypeEvents(): removing event\n");
|
||||
/*
|
||||
* Found an event of this type for the window, remove it.
|
||||
* The iterator will become invalid.
|
||||
*/
|
||||
delete event;
|
||||
m_events.erase(iter);
|
||||
iter = m_events.begin();
|
||||
}
|
||||
else
|
||||
{
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GHOST_IEvent* GHOST_EventManager::popEvent()
|
||||
{
|
||||
GHOST_IEvent* event = peekEvent();
|
||||
|
@@ -129,6 +129,28 @@ public:
|
||||
*/
|
||||
virtual GHOST_TSuccess removeConsumer(GHOST_IEventConsumer* consumer);
|
||||
|
||||
/**
|
||||
* Removes all events for a window from the stack.
|
||||
* @param window The window to remove events for.
|
||||
*/
|
||||
virtual void
|
||||
removeWindowEvents(
|
||||
GHOST_IWindow* window
|
||||
);
|
||||
|
||||
/**
|
||||
* Removes all events of a certain type from the stack.
|
||||
* The window parameter is optional. If non-null, the routine will remove
|
||||
* events only associated with that window.
|
||||
* @param type The type of events to be removed.
|
||||
* @param window The window to remove the events for.
|
||||
*/
|
||||
virtual void
|
||||
removeTypeEvents(
|
||||
GHOST_TEventType type,
|
||||
GHOST_IWindow* window = 0
|
||||
);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Returns the event at the top of the stack and removes it.
|
||||
@@ -142,10 +164,15 @@ protected:
|
||||
*/
|
||||
virtual void disposeEvents();
|
||||
|
||||
/** A stack with events. */
|
||||
typedef std::deque<GHOST_IEvent*> TEventStack;
|
||||
|
||||
/** The event stack. */
|
||||
std::deque<GHOST_IEvent*> m_events;
|
||||
|
||||
/** A vector with event consumers. */
|
||||
typedef std::vector<GHOST_IEventConsumer*> TConsumerVector;
|
||||
|
||||
/** The list with event consumers. */
|
||||
TConsumerVector m_consumers;
|
||||
};
|
||||
|
@@ -106,6 +106,13 @@ GHOST_TSuccess GHOST_System::removeTimer(GHOST_ITimerTask* timerTask)
|
||||
GHOST_TSuccess GHOST_System::disposeWindow(GHOST_IWindow* window)
|
||||
{
|
||||
GHOST_TSuccess success;
|
||||
|
||||
/*
|
||||
* Remove all pending events for the window.
|
||||
*/
|
||||
if (m_windowManager->getWindowFound(window)) {
|
||||
m_eventManager->removeWindowEvents(window);
|
||||
}
|
||||
if (window == m_windowManager->getFullScreenWindow()) {
|
||||
success = endFullScreen();
|
||||
}
|
||||
@@ -165,7 +172,7 @@ GHOST_TSuccess GHOST_System::endFullScreen(void)
|
||||
GHOST_TSuccess success = GHOST_kFailure;
|
||||
GHOST_ASSERT(m_windowManager, "GHOST_System::endFullScreen(): invalid window manager")
|
||||
if (m_windowManager->getFullScreen()) {
|
||||
GHOST_IWindow* window = m_windowManager->getFullScreenWindow();
|
||||
//GHOST_IWindow* window = m_windowManager->getFullScreenWindow();
|
||||
//GHOST_PRINT("GHOST_System::endFullScreen(): leaving window manager full-screen mode\n");
|
||||
success = m_windowManager->endFullScreen();
|
||||
GHOST_ASSERT(m_displayManager, "GHOST_System::endFullScreen(): invalid display manager")
|
||||
|
Reference in New Issue
Block a user