[ekiga] Opal: Fixed crash on exit when a call is still in the collection.



commit 6b639422e6a58788566696fefee0dad8733a4d9e
Author: Damien Sandras <dsandras seconix com>
Date:   Sun Oct 11 14:35:05 2015 +0200

    Opal: Fixed crash on exit when a call is still in the collection.

 .../components/opal/process/opal-endpoint.cpp      |   17 +++++++++++------
 lib/engine/components/opal/process/opal-endpoint.h |    2 ++
 2 files changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/lib/engine/components/opal/process/opal-endpoint.cpp 
b/lib/engine/components/opal/process/opal-endpoint.cpp
index 53e2969..d416828 100644
--- a/lib/engine/components/opal/process/opal-endpoint.cpp
+++ b/lib/engine/components/opal/process/opal-endpoint.cpp
@@ -164,6 +164,8 @@ Opal::EndPoint::EndPoint (Ekiga::ServiceCore& _core) : core(_core)
 #ifdef HAVE_H323
   h323_endpoint= new H323::EndPoint (*this, core);
 #endif
+
+  call_core = core.get<Ekiga::CallCore> ("call-core");
 }
 
 
@@ -173,6 +175,11 @@ Opal::EndPoint::~EndPoint ()
     stun_thread->WaitForTermination ();
 
   g_async_queue_unref (queue);
+
+  for (PSafePtr<OpalCall> call = activeCalls; call != NULL; ++call)
+    DestroyCall (call);
+
+  activeCalls.RemoveAll (TRUE);
 }
 
 
@@ -476,7 +483,6 @@ void Opal::EndPoint::GetVideoOptions (Opal::EndPoint::VideoOptions & options) co
 
 OpalCall *Opal::EndPoint::CreateCall (void *uri)
 {
-  boost::shared_ptr<Ekiga::CallCore> call_core = core.get<Ekiga::CallCore> ("call-core");
   boost::shared_ptr<Opal::Call> call = Opal::Call::create (*this, uri ? (const char*) uri : std::string (), 
noAnswerDelay);
 
   Ekiga::Runtime::run_in_main (boost::bind (&Ekiga::CallCore::add_call, call_core, call));
@@ -496,9 +502,10 @@ Opal::EndPoint::DestroyCall (OpalCall *__call)
    * be destroyed by boost.
    */
   Opal::Call *_call = dynamic_cast<Opal::Call *>(__call);
-  boost::shared_ptr<Ekiga::CallCore> call_core = core.get<Ekiga::CallCore> ("call-core");
-  if (_call)
-    Ekiga::Runtime::run_in_main (boost::bind (static_cast<void 
(Opal::EndPoint::*)(boost::shared_ptr<Ekiga::Call>)>(&Opal::EndPoint::DestroyCall), this, 
_call->shared_from_this ()));
+  if (_call) {
+    boost::shared_ptr<Ekiga::Call> call = _call->shared_from_this ();
+    Ekiga::Runtime::run_in_main (boost::bind (static_cast<void 
(Opal::EndPoint::*)(boost::shared_ptr<Ekiga::Call>)>(&Opal::EndPoint::DestroyCall), this, call));
+  }
 }
 
 
@@ -557,8 +564,6 @@ Opal::EndPoint::HandleSTUNResult ()
 void
 Opal::EndPoint::ReportSTUNError (const std::string error)
 {
-  boost::shared_ptr<Ekiga::CallCore> call_core = core.get<Ekiga::CallCore> ("call-core");
-
   // notice we're in for an infinite loop if nobody ever reports to the user!
   if (!call_core->errors (error))
     Ekiga::Runtime::run_in_main (boost::bind (&Opal::EndPoint::ReportSTUNError, this, error), 10);
diff --git a/lib/engine/components/opal/process/opal-endpoint.h 
b/lib/engine/components/opal/process/opal-endpoint.h
index c36860a..92ee889 100644
--- a/lib/engine/components/opal/process/opal-endpoint.h
+++ b/lib/engine/components/opal/process/opal-endpoint.h
@@ -170,6 +170,8 @@ private:
 #ifdef HAVE_H323
     H323::EndPoint *h323_endpoint;
 #endif
+    /* Make sure the CallCore is destroyed after the EndPoint */
+    boost::shared_ptr<Ekiga::CallCore> call_core;
     Ekiga::ServiceCore& core;
   };
 };


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]