From 93236223dac3af2ee2b4b40b07d4128bff8ea653 Mon Sep 17 00:00:00 2001 From: Andreas Monzner Date: Tue, 12 Dec 2006 19:36:32 +0000 Subject: [PATCH] fix bug in mainloop (this fixes sometimes no more responding e2) --- lib/base/ebase.cpp | 16 ++++++++++++++-- lib/base/ebase.h | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/base/ebase.cpp b/lib/base/ebase.cpp index 480c8ea8..e5168096 100644 --- a/lib/base/ebase.cpp +++ b/lib/base/ebase.cpp @@ -118,7 +118,8 @@ void eMainloop::addSocketNotifier(eSocketNotifier *sn) { int fd = sn->getFD(); ASSERT(notifiers.find(fd) == notifiers.end()); - notifiers[fd]=sn; + ASSERT(new_notifiers.find(fd) == new_notifiers.end()); + new_notifiers[fd]=sn; } void eMainloop::removeSocketNotifier(eSocketNotifier *sn) @@ -128,6 +129,11 @@ void eMainloop::removeSocketNotifier(eSocketNotifier *sn) ++i) if (i->second == sn) return notifiers.erase(i); + for (std::map::iterator i = new_notifiers.find(sn->getFD()); + i != new_notifiers.end(); + ++i) + if (i->second == sn) + return new_notifiers.erase(i); eFatal("removed socket notifier which is not present"); } @@ -164,7 +170,13 @@ int eMainloop::processOneEvent(unsigned int user_timeout, PyObject **res, ePyObj poll_timeout = user_timeout; return_reason = 1; } - + + for (std::map::iterator it(new_notifiers.begin()); it != new_notifiers.end();) + { + notifiers[it->first]=it->second; + new_notifiers.erase(it++); + } + int nativecount=notifiers.size(), fdcount=nativecount, ret=0; diff --git a/lib/base/ebase.h b/lib/base/ebase.h index a399667e..db936794 100644 --- a/lib/base/ebase.h +++ b/lib/base/ebase.h @@ -175,7 +175,7 @@ class eMainloop { friend class eTimer; friend class eSocketNotifier; - std::map notifiers; + std::map notifiers, new_notifiers; ePtrList m_timer_list; bool app_quit_now; int loop_level; -- 2.30.2