diff options
author | Sam Spilsbury <Sam@XPS-SUSE.site> | 2009-03-16 14:18:55 +0900 |
---|---|---|
committer | Sam Spilsbury <Sam@XPS-SUSE.site> | 2009-03-16 14:18:55 +0900 |
commit | 5a1d68bbcd04bb04b394822b428c6faa3d4adb9c (patch) | |
tree | 9d59ae3a39dda1ef8f6e4af3de8ea2691b944c52 | |
parent | d84a264d5749a990129e37a31e79f5e8d6b8d2d2 (diff) | |
download | mousepoll-5a1d68bbcd04bb04b394822b428c6faa3d4adb9c.tar.gz mousepoll-5a1d68bbcd04bb04b394822b428c6faa3d4adb9c.tar.bz2 |
Handle change in list size due to callback
-rw-r--r-- | mousepoll.cpp | 25 | ||||
-rw-r--r-- | mousepoll.h | 4 |
2 files changed, 15 insertions, 14 deletions
diff --git a/mousepoll.cpp b/mousepoll.cpp index fdd711d..62de988 100644 --- a/mousepoll.cpp +++ b/mousepoll.cpp @@ -53,21 +53,21 @@ MousepollScreen::getMousePosition () bool MousepollScreen::updatePosition () { - if (pollers.empty ()) - return false; if (getMousePosition ()) { - std::list<MousePoller *>::iterator it; - for (it = pollers.begin (); it != pollers.end (); it++) - { - MousePoller *poller = *it; - - poller->mPoint = pos; - poller->mCallback (pos); - } + std::list<MousePoller *>::iterator it; + for (it = pollers.begin (); it != pollers.end (); ) + { + MousePoller *poller = *it; + + it++; + poller->mPoint = pos; + poller->mCallback (pos); + } } + return true; } @@ -101,7 +101,7 @@ MousepollScreen::removeTimer (MousePoller *poller) if (it == pollers.end ()) return; - pollers.remove (it); + pollers.erase (it); if (pollers.empty ()) timer.stop (); @@ -255,7 +255,8 @@ MousepollScreen::setOption (const char *name, MousepollScreen::MousepollScreen (CompScreen *screen) : PrivateHandler <MousepollScreen, CompScreen, COMPIZ_MOUSEPOLL_ABI> (screen), - opt (MP_OPTION_NUM) + opt (MP_OPTION_NUM), + empty (true) { int timeout; diff --git a/mousepoll.h b/mousepoll.h index 7061792..e0469fd 100644 --- a/mousepoll.h +++ b/mousepoll.h @@ -52,9 +52,9 @@ class MousePoller private: - bool mActive; + bool mActive; CompPoint mPoint; - CallBack mCallback; + CallBack mCallback; friend class MousepollScreen; }; |