fix bug in mainloop (this fixes sometimes no more responding e2)
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Tue, 12 Dec 2006 19:36:32 +0000 (19:36 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Tue, 12 Dec 2006 19:36:32 +0000 (19:36 +0000)
lib/base/ebase.cpp
lib/base/ebase.h

index 480c8ea8d2a8d48e70ff7e6b8e5ddc0bb697aef7..e51680966e43f08a00671a6740cff9c36f263ddd 100644 (file)
@@ -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<int,eSocketNotifier*>::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<int, eSocketNotifier*>::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;
index a399667e5417f71c866675baeb5c59bdd65dfc34..db936794df3425f403b05d07f727fb6255a1da93 100644 (file)
@@ -175,7 +175,7 @@ class eMainloop
 {
        friend class eTimer;
        friend class eSocketNotifier;
-       std::map<int, eSocketNotifier*> notifiers;
+       std::map<int, eSocketNotifier*> notifiers, new_notifiers;
        ePtrList<eTimer> m_timer_list;
        bool app_quit_now;
        int loop_level;