[ekiga] Opal::Presentity: Fixed crash.



commit 208bc332c3cbbd253383f62061db9496f791a659
Author: Damien Sandras <dsandras seconix com>
Date:   Sat Oct 3 18:01:43 2015 +0200

    Opal::Presentity: Fixed crash.
    
    This was due to the fact we need to use shared_from_this in the
    callback.
    
    Consequently, actions loading have been moved outside of the
    constructor.

 lib/engine/components/opal/opal-presentity.cpp |   23 +++++++++++++++++------
 lib/engine/components/opal/opal-presentity.h   |    2 ++
 2 files changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/lib/engine/components/opal/opal-presentity.cpp b/lib/engine/components/opal/opal-presentity.cpp
index a0f2726..6a6d232 100644
--- a/lib/engine/components/opal/opal-presentity.cpp
+++ b/lib/engine/components/opal/opal-presentity.cpp
@@ -107,6 +107,7 @@ Opal::Presentity::create (const Account & _account,
                                                                _presence_core,
                                                                _existing_groups,
                                                                _node));
+  presentity->add_actions ();
 
   return presentity;
 }
@@ -122,6 +123,20 @@ Opal::Presentity::Presentity (const Opal::Account & account_,
   node(node_),
   presence("unknown")
 {
+}
+
+
+Opal::Presentity::~Presentity ()
+{
+#if DEBUG
+    std::cout << "Opal::Presentity: Destructor invoked" << std::endl;
+#endif
+}
+
+
+void
+Opal::Presentity::add_actions ()
+{
   /* Pull actions */
   boost::shared_ptr<Ekiga::PresenceCore> pcore = presence_core.lock ();
   if (pcore)
@@ -131,15 +146,11 @@ Opal::Presentity::Presentity (const Opal::Account & account_,
                                                    boost::bind (&Opal::Presentity::edit_presentity, this))));
   add_action (Ekiga::ActionPtr (new Ekiga::Action ("remove", _("_Remove"),
                                                    boost::bind (&Opal::Presentity::remove, this))));
+  std::cout << "Crash HERE" << std::endl;
   add_action (Ekiga::ActionPtr (new Ekiga::Action ("rename", _("Rename _Groups"),
                                                    boost::bind (&Opal::Account::on_rename_group,
                                                                 (Opal::Account *) &account,
-                                                                PresentityPtr (this)))));
-}
-
-
-Opal::Presentity::~Presentity ()
-{
+                                                                this->shared_from_this ()))));
 }
 
 
diff --git a/lib/engine/components/opal/opal-presentity.h b/lib/engine/components/opal/opal-presentity.h
index 92dd050..d29498e 100644
--- a/lib/engine/components/opal/opal-presentity.h
+++ b/lib/engine/components/opal/opal-presentity.h
@@ -125,6 +125,8 @@ namespace Opal
                 boost::function0<std::list<std::string> > existing_groups_,
                 xmlNodePtr node_);
 
+    void add_actions ();
+
     /* this pair of method is to let the user edit the presentity with
      * a nice form
      */


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