ekiga r7826 - trunk/lib/engine/components/libnotify



Author: jpuydt
Date: Sat Mar 28 20:08:59 2009
New Revision: 7826
URL: http://svn.gnome.org/viewvc/ekiga?rev=7826&view=rev

Log:
Fixed small leaks in libnotify code

Modified:
   trunk/lib/engine/components/libnotify/libnotify-main.cpp

Modified: trunk/lib/engine/components/libnotify/libnotify-main.cpp
==============================================================================
--- trunk/lib/engine/components/libnotify/libnotify-main.cpp	(original)
+++ trunk/lib/engine/components/libnotify/libnotify-main.cpp	Sat Mar 28 20:08:59 2009
@@ -36,6 +36,7 @@
  */
 
 #include <map>
+#include <tr1/memory>
 
 #include <libnotify/notify.h>
 
@@ -44,7 +45,10 @@
 
 #include "libnotify-main.h"
 
-class LibNotify: public Ekiga::Service
+
+class LibNotify:
+  public Ekiga::Service,
+  public sigc::trackable
 {
 public:
 
@@ -63,7 +67,7 @@
   void on_notification_added (gmref_ptr<Ekiga::Notification> notif);
   void on_notification_removed (gmref_ptr<Ekiga::Notification> notif);
 
-  typedef std::map<gmref_ptr<Ekiga::Notification>, std::pair<sigc::connection, NotifyNotification*> > container_type;
+  typedef std::map<gmref_ptr<Ekiga::Notification>, std::pair<sigc::connection, std::tr1::shared_ptr<NotifyNotification> > > container_type;
   container_type live;
 };
 
@@ -114,15 +118,6 @@
 
 LibNotify::~LibNotify ()
 {
-  for (container_type::iterator iter = live.begin ();
-       iter != live.end ();
-       ++iter) {
-
-    iter->second.first.disconnect ();
-    g_object_unref (iter->second.second);
-  }
-  live.clear ();
-
   notify_uninit ();
 }
 
@@ -169,7 +164,7 @@
 		    G_CALLBACK (on_notif_closed), notification.get ());
   sigc::connection conn = notification->removed.connect (sigc::bind (sigc::mem_fun (this, &LibNotify::on_notification_removed), notification));
 
-  live[notification] = std::pair<sigc::connection, NotifyNotification*> (conn, notif);
+  live[notification] = std::pair<sigc::connection, std::tr1::shared_ptr<NotifyNotification> > (conn, std::tr1::shared_ptr<NotifyNotification> (notif, g_object_unref));
 
   (void)notify_notification_show (notif, NULL);
 }
@@ -182,7 +177,6 @@
   if (iter != live.end ()) {
 
     iter->second.first.disconnect ();
-    g_object_unref (iter->second.second);
     live.erase (iter);
   }
 }



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