From d95fcc2dbba7fdf3884452bd69c352c87ae1e57b Mon Sep 17 00:00:00 2001 From: rathnor Date: Tue, 4 May 2004 14:33:38 +0000 Subject: Event Manager fixes/review --- ChangeLog | 3 +++ src/Container.cc | 4 ++-- src/FbTk/EventManager.cc | 18 +++++++++++++----- src/FbTk/EventManager.hh | 9 ++++++--- src/IconButton.cc | 4 ++-- src/SystemTray.cc | 3 ++- 6 files changed, 28 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index ab06eb4..17b0da1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ (Format: Year/Month/Day) Changes for 0.9.10: +*04/05/04: + * Fix EventManager bug/memory leak (possibly caused crash) (Simon) + EventManager.hh/cc *04/05/02: * Added new nls item for windowmenu: Layer nls/C/Windowmenu.m diff --git a/src/Container.cc b/src/Container.cc index a53901d..5d07552 100644 --- a/src/Container.cc +++ b/src/Container.cc @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Container.cc,v 1.13 2004/01/21 13:34:40 fluxgen Exp $ +// $Id: Container.cc,v 1.14 2004/05/04 14:33:37 rathnor Exp $ #include "Container.hh" @@ -37,7 +37,7 @@ Container::Container(const FbTk::FbWindow &parent): } Container::~Container() { - + // ~FbWindow cleans event manager } void Container::resize(unsigned int width, unsigned int height) { diff --git a/src/FbTk/EventManager.cc b/src/FbTk/EventManager.cc index 9a11ab2..d4f4f4c 100644 --- a/src/FbTk/EventManager.cc +++ b/src/FbTk/EventManager.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: EventManager.cc,v 1.11 2004/04/19 22:46:46 fluxgen Exp $ +// $Id: EventManager.cc,v 1.12 2004/05/04 14:33:38 rathnor Exp $ #include "EventManager.hh" #include "FbWindow.hh" @@ -128,11 +128,19 @@ void EventManager::unregisterEventHandler(Window win) { void EventManager::dispatch(Window win, XEvent &ev, bool parent) { EventHandler *evhand = 0; - if (parent) - evhand = m_parent[win]; - else { + if (parent) { + EventHandlerMap::iterator it = m_parent.find(win); + if (it == m_parent.end()) + return; + else + evhand = it->second; + } else { win = getEventWindow(ev); - evhand = m_eventhandlers[win]; + EventHandlerMap::iterator it = m_eventhandlers.find(win); + if (it == m_eventhandlers.end()) + return; + else + evhand = it->second; } if (evhand == 0) diff --git a/src/FbTk/EventManager.hh b/src/FbTk/EventManager.hh index 049d527..6bd368c 100644 --- a/src/FbTk/EventManager.hh +++ b/src/FbTk/EventManager.hh @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: EventManager.hh,v 1.8 2004/04/19 22:46:46 fluxgen Exp $ +// $Id: EventManager.hh,v 1.9 2004/05/04 14:33:38 rathnor Exp $ #include "EventHandler.hh" #include @@ -51,12 +51,15 @@ public: void registerEventHandler(EventHandler &ev, Window win); void unregisterEventHandler(Window win); + private: EventManager() { } ~EventManager(); void dispatch(Window win, XEvent &event, bool parent = false); - std::map m_eventhandlers; - std::map m_parent; + + typedef std::map EventHandlerMap; + EventHandlerMap m_eventhandlers; + EventHandlerMap m_parent; }; } //end namespace FbTk diff --git a/src/IconButton.cc b/src/IconButton.cc index c572604..6f0b0b7 100644 --- a/src/IconButton.cc +++ b/src/IconButton.cc @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: IconButton.cc,v 1.19 2004/05/02 20:46:19 fluxgen Exp $ +// $Id: IconButton.cc,v 1.20 2004/05/04 14:33:37 rathnor Exp $ #include "IconButton.hh" @@ -112,7 +112,7 @@ IconButton::IconButton(const FbTk::FbWindow &parent, const FbTk::Font &font, } IconButton::~IconButton() { - + // ~FbWindow cleans event manager } diff --git a/src/SystemTray.cc b/src/SystemTray.cc index 7214c20..5e28681 100644 --- a/src/SystemTray.cc +++ b/src/SystemTray.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: SystemTray.cc,v 1.9 2004/04/19 22:49:25 fluxgen Exp $ +// $Id: SystemTray.cc,v 1.10 2004/05/04 14:33:37 rathnor Exp $ #include "SystemTray.hh" @@ -141,6 +141,7 @@ SystemTray::~SystemTray() { // remove us, else fluxbox might delete the memory too Fluxbox::instance()->removeAtomHandler(m_handler.get()); removeAllClients(); + // ~FbWindow cleans EventManager } void SystemTray::move(int x, int y) { -- cgit v0.11.2