fix frequently segfault on clean shutdown
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Wed, 14 Nov 2007 14:56:16 +0000 (14:56 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Wed, 14 Nov 2007 14:56:16 +0000 (14:56 +0000)
lib/base/ebase.cpp
lib/base/ebase.h
lib/dvb/dvb.h

index 08c1561..effd725 100644 (file)
@@ -116,6 +116,16 @@ void eTimer::addTimeOffset( int offset )
 // mainloop
 ePtrList<eMainloop> eMainloop::existing_loops;
 
+eMainloop::~eMainloop()
+{
+       existing_loops.remove(this);
+       pthread_mutex_destroy(&recalcLock);
+       for (std::map<int, eSocketNotifier*>::iterator it(notifiers.begin());it != notifiers.end();++it)
+               it->second->stop();
+       while(m_timer_list.begin() != m_timer_list.end())
+               m_timer_list.begin()->stop();
+}
+
 void eMainloop::addSocketNotifier(eSocketNotifier *sn)
 {
        int fd = sn->getFD();
index bab1b5f..4378711 100644 (file)
@@ -217,13 +217,7 @@ public:
                existing_loops.push_back(this);
                pthread_mutex_init(&recalcLock, 0);
        }
-       virtual ~eMainloop()
-       {
-               existing_loops.remove(this);
-               pthread_mutex_destroy(&recalcLock);
-               for (std::map<int, eSocketNotifier*>::iterator it(notifiers.begin());it != notifiers.end();++it)
-                       it->second->stop();
-       }
+       virtual ~eMainloop();
 
        int looplevel() { return loop_level; }
 
index b23d047..e09f0fa 100644 (file)
@@ -33,9 +33,12 @@ public:
        eDVBRegisteredFrontend(eDVBFrontend *fe, iDVBAdapter *adap)
                :disable(new eTimer(eApp)), m_adapter(adap), m_frontend(fe), m_inuse(0)
        {
-               disable = new eTimer(eApp);
                CONNECT(disable->timeout, eDVBRegisteredFrontend::closeFrontend);
        }
+       ~eDVBRegisteredFrontend()
+       {
+               delete disable;
+       }
        void dec_use()
        {
                if (!--m_inuse)