[ekiga] loudmouth(XMPP): simpler management of message handlers -- fixes a crash when removing a connected a



commit f8a36b3fe03f554a050d90b634fde68f8b989fe2
Author: Julien Puydt <jpuydt free fr>
Date:   Wed Jun 6 11:23:16 2012 +0200

    loudmouth(XMPP): simpler management of message handlers -- fixes a crash when removing a connected account

 plugins/loudmouth/loudmouth-account.cpp |   21 ++++++---------------
 plugins/loudmouth/loudmouth-account.h   |    4 ----
 2 files changed, 6 insertions(+), 19 deletions(-)
---
diff --git a/plugins/loudmouth/loudmouth-account.cpp b/plugins/loudmouth/loudmouth-account.cpp
index b16f762..48d053e 100644
--- a/plugins/loudmouth/loudmouth-account.cpp
+++ b/plugins/loudmouth/loudmouth-account.cpp
@@ -127,14 +127,17 @@ LM::Account::Account (boost::shared_ptr<Ekiga::PersonalDetails> details_,
 
   connection = lm_connection_new (NULL);
 
-  iq_lm_handler = lm_message_handler_new ((LmHandleMessageFunction)iq_handler_c, this, NULL);
+  LmMessageHandler* iq_lm_handler = lm_message_handler_new ((LmHandleMessageFunction)iq_handler_c, this, NULL);
   lm_connection_register_message_handler (connection, iq_lm_handler, LM_MESSAGE_TYPE_IQ, LM_HANDLER_PRIORITY_NORMAL);
+  lm_message_handler_unref (iq_lm_handler);
 
-  presence_lm_handler = lm_message_handler_new ((LmHandleMessageFunction)presence_handler_c, this, NULL);
+  LmMessageHandler* presence_lm_handler = lm_message_handler_new ((LmHandleMessageFunction)presence_handler_c, this, NULL);
   lm_connection_register_message_handler (connection, presence_lm_handler, LM_MESSAGE_TYPE_PRESENCE, LM_HANDLER_PRIORITY_NORMAL);
+  lm_message_handler_unref (presence_lm_handler);
 
-  message_lm_handler = lm_message_handler_new ((LmHandleMessageFunction)message_handler_c, this, NULL);
+  LmMessageHandler* message_lm_handler = lm_message_handler_new ((LmHandleMessageFunction)message_handler_c, this, NULL);
   lm_connection_register_message_handler (connection, message_lm_handler, LM_MESSAGE_TYPE_MESSAGE, LM_HANDLER_PRIORITY_NORMAL);
+  lm_message_handler_unref (message_lm_handler);
 
   lm_connection_set_disconnect_function (connection, (LmDisconnectFunction)on_disconnected_c,
 					 this, NULL);
@@ -266,18 +269,6 @@ LM::Account::~Account ()
     lm_connection_close (connection, NULL);
   }
 
-  lm_connection_unregister_message_handler (connection, iq_lm_handler, LM_MESSAGE_TYPE_IQ);
-  lm_message_handler_unref (iq_lm_handler);
-  iq_lm_handler = 0;
-
-  lm_connection_unregister_message_handler (connection, presence_lm_handler, LM_MESSAGE_TYPE_PRESENCE);
-  lm_message_handler_unref (presence_lm_handler);
-  presence_lm_handler = 0;
-
-  lm_connection_unregister_message_handler (connection, message_lm_handler, LM_MESSAGE_TYPE_MESSAGE);
-  lm_message_handler_unref (message_lm_handler);
-  message_lm_handler = 0;
-
   lm_connection_unref (connection);
   connection = 0;
 }
diff --git a/plugins/loudmouth/loudmouth-account.h b/plugins/loudmouth/loudmouth-account.h
index 4fa6ea4..c7a86b2 100644
--- a/plugins/loudmouth/loudmouth-account.h
+++ b/plugins/loudmouth/loudmouth-account.h
@@ -101,10 +101,6 @@ namespace LM
 
   private:
 
-    LmMessageHandler* iq_lm_handler;
-    LmMessageHandler* presence_lm_handler;
-    LmMessageHandler* message_lm_handler;
-
     void edit ();
     void on_edit_form_submitted (bool submitted,
 				 Ekiga::Form &result);



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