From 81b7084fcac418eda985558e51af4cfd72248dd2 Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 13 Mar 2003 01:28:30 +0000 Subject: [PATCH] minor event refinements --- panda/src/event/eventQueue.cxx | 14 ++++++++++++++ panda/src/event/eventQueue.h | 2 +- panda/src/framework/pandaFramework.cxx | 17 +++++++++++++---- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/panda/src/event/eventQueue.cxx b/panda/src/event/eventQueue.cxx index 6a09390509..f475a39e11 100644 --- a/panda/src/event/eventQueue.cxx +++ b/panda/src/event/eventQueue.cxx @@ -68,6 +68,20 @@ queue_event(CPT_Event event) { } } +//////////////////////////////////////////////////////////////////// +// Function: EventQueue::clear +// Access: Public +// Description: Empties all events on the queue, throwing them on the +// floor. +//////////////////////////////////////////////////////////////////// +void EventQueue:: +clear() { + while (!_queue.empty()) { + _queue.pop_front(); + } +} + + //////////////////////////////////////////////////////////////////// // Function: EventQueue::is_queue_empty // Access: Public diff --git a/panda/src/event/eventQueue.h b/panda/src/event/eventQueue.h index abdf312b40..7896fc2739 100644 --- a/panda/src/event/eventQueue.h +++ b/panda/src/event/eventQueue.h @@ -46,7 +46,7 @@ PUBLISHED: ~EventQueue(); void queue_event(CPT_Event event); - + void clear(); bool is_queue_empty() const; bool is_queue_full() const; diff --git a/panda/src/framework/pandaFramework.cxx b/panda/src/framework/pandaFramework.cxx index c00cadadea..634faa12ae 100644 --- a/panda/src/framework/pandaFramework.cxx +++ b/panda/src/framework/pandaFramework.cxx @@ -966,10 +966,19 @@ event_window_event(CPT_Event event, void *data) { const GraphicsWindow *win; DCAST_INTO_V(win, param.get_ptr()); - if (!win->get_properties().get_open()) { - // If the last window was closed, exit the application. - if (self->all_windows_closed()) { - self->_exit_flag = true; + // Is this a window we've heard about? + int window_index = self->find_window(win); + if (window_index == -1) { + framework_cat.warning() + << "Ignoring message from unknown window.\n"; + } else { + if (!win->get_properties().get_open()) { + // If the last window was closed, exit the application. + if (self->all_windows_closed() && !self->_exit_flag) { + framework_cat.info() + << "Last window was closed by user.\n"; + self->_exit_flag = true; + } } } }