[glibmm] DBus[Connection|Proxy]: Don't take extra reference on async creation.



commit b0c4b88b3a99b613bd20aefd40b2bad172c64e09
Author: José Alburquerque <jaalburqu svn gnome org>
Date:   Tue Dec 14 22:53:50 2010 -0500

    	DBus[Connection|Proxy]: Don't take extra reference on async creation.
    
    	* gio/src/dbusconnection.ccg:
    	* gio/src/dbusproxy.ccg: There's no need to put the newly constructed
    	DBusConnection|DBusProxy in a Glib::RefPtr<> and then take an extra
    	reference.  Simply constructing the object is enough to guarantee that
    	the object continues existing until the SlotAsyncReady slot is called.

 ChangeLog                  |   10 +++++++
 gio/src/dbusconnection.ccg |   62 +++++--------------------------------------
 gio/src/dbusproxy.ccg      |   30 ++++-----------------
 3 files changed, 24 insertions(+), 78 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0485891..0bdb096 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2010-12-14  José Alburquerque  <jaalburqu svn gnome org>
+
+	DBus[Connection|Proxy]: Don't take extra reference on async creation.
+
+	* gio/src/dbusconnection.ccg:
+	* gio/src/dbusproxy.ccg: There's no need to put the newly constructed
+	DBusConnection|DBusProxy in a Glib::RefPtr<> and then take an extra
+	reference.  Simply constructing the object is enough to guarantee that
+	the object continues existing until the SlotAsyncReady slot is called.
+
 2010-12-13  José Alburquerque  <jaalburqu svn gnome org>
 
 	DBusProxy: Reorder the parameters so that "name" is second in methods.
diff --git a/gio/src/dbusconnection.ccg b/gio/src/dbusconnection.ccg
index f224e2b..ca94e3f 100644
--- a/gio/src/dbusconnection.ccg
+++ b/gio/src/dbusconnection.ccg
@@ -297,12 +297,7 @@ void DBusConnection::create(const Glib::RefPtr<IOStream>& stream,
   // Note that this does not return anything, because it is async - see
   // create_finish().
 
-  // Create the connection, taking an extra reference without returning it.
-  // The extra reference is taken so the connection is not destroyed when it
-  // goes out of scope.  The finished connection will be returned in the slot
-  // by calling create_finish().
-  Glib::RefPtr<DBusConnection>(new DBusConnection(stream, guid, observer,
-    slot, cancellable, flags))->reference();
+  DBusConnection(stream, guid, observer, slot, cancellable, flags);
 }
 
 //static
@@ -315,12 +310,7 @@ void DBusConnection::create(const Glib::RefPtr<IOStream>& stream,
   // Note that this does not return anything, because it is async - see
   // create_finish().
 
-  // Create the connection, taking an extra reference without returning it.
-  // The extra reference is taken so the connection is not destroyed when it
-  // goes out of scope.  The finished connection will be returned in the slot
-  // by calling create_finish().
-  Glib::RefPtr<DBusConnection>(new DBusConnection(stream, guid, slot,
-    cancellable, flags))->reference();
+  DBusConnection(stream, guid, slot, cancellable, flags);
 }
 
 //static
@@ -332,13 +322,7 @@ void DBusConnection::create(const Glib::RefPtr<IOStream>& stream,
 {
   // Note that this does not return anything, because it is async - see
   // create_finish().
-
-  // Create the connection, taking an extra reference without returning it.
-  // The extra reference is taken so the connection is not destroyed when it
-  // goes out of scope.  The finished connection will be returned in the slot
-  // by calling create_finish().
-  Glib::RefPtr<DBusConnection>(new DBusConnection(stream, guid, observer,
-    slot, flags))->reference();
+  DBusConnection(stream, guid, observer, slot, flags);
 }
 
 //static
@@ -349,13 +333,7 @@ void DBusConnection::create(const Glib::RefPtr<IOStream>& stream,
 {
   // Note that this does not return anything, because it is async - see
   // create_finish().
-
-  // Create the connection, taking an extra reference without returning it.
-  // The extra reference is taken so the connection is not destroyed when it
-  // goes out of scope.  The finished connection will be returned in the slot
-  // by calling create_finish().
-  Glib::RefPtr<DBusConnection>(new DBusConnection(stream, guid, slot,
-    flags))->reference();
+  DBusConnection(stream, guid, slot, flags);
 }
 
 //static
@@ -411,13 +389,7 @@ void DBusConnection::create_for_address(const Glib::ustring& address,
 {
   // Note that this does not return anything, because it is async - see
   // create_finish().
-
-  // Create the connection, taking an extra reference without returning it.
-  // The extra reference is taken so the connection is not destroyed when it
-  // goes out of scope.  The finished connection will be returned in the slot
-  // by calling create_finish().
-  Glib::RefPtr<DBusConnection>(new DBusConnection(address, observer, slot,
-    cancellable, flags))->reference();
+  DBusConnection(address, observer, slot, cancellable, flags);
 }
 
 //static
@@ -428,13 +400,7 @@ void DBusConnection::create_for_address(const Glib::ustring& address,
 {
   // Note that this does not return anything, because it is async - see
   // create_finish().
-
-  // Create the connection, taking an extra reference without returning it.
-  // The extra reference is taken so the connection is not destroyed when it
-  // goes out of scope.  The finished connection will be returned in the slot
-  // by calling create_finish().
-  Glib::RefPtr<DBusConnection>(new DBusConnection(address, slot, cancellable,
-    flags))->reference();
+  DBusConnection(address, slot, cancellable, flags);
 }
 
 //static
@@ -445,13 +411,7 @@ void DBusConnection::create_for_address(const Glib::ustring& address,
 {
   // Note that this does not return anything, because it is async - see
   // create_finish().
-
-  // Create the connection, taking an extra reference without returning it.
-  // The extra reference is taken so the connection is not destroyed when it
-  // goes out of scope.  The finished connection will be returned in the slot
-  // by calling create_finish().
-  Glib::RefPtr<DBusConnection>(new DBusConnection(address, observer, slot,
-    flags))->reference();
+  DBusConnection(address, observer, slot, flags);
 }
 
 //static
@@ -461,13 +421,7 @@ void DBusConnection::create_for_address(const Glib::ustring& address,
 {
   // Note that this does not return anything, because it is async - see
   // create_finish().
-
-  // Create the connection, taking an extra reference without returning it.
-  // The extra reference is taken so the connection is not destroyed when it
-  // goes out of scope.  The finished connection will be returned in the slot
-  // by calling create_finish().
-  Glib::RefPtr<DBusConnection>(new DBusConnection(address, slot,
-    flags))->reference();
+  DBusConnection(address, slot, flags);
 }
 
 //static
diff --git a/gio/src/dbusproxy.ccg b/gio/src/dbusproxy.ccg
index ad9a85a..3df1754 100644
--- a/gio/src/dbusproxy.ccg
+++ b/gio/src/dbusproxy.ccg
@@ -179,12 +179,8 @@ void DBusProxy::create(const Glib::RefPtr<DBusConnection>& connection,
   const Glib::RefPtr<DBusInterfaceInfo>& info,
   DBusProxyFlags flags)
 {
-  // Create the proxy, taking an extra reference without returning it.  The
-  // extra reference is taken so the proxy is not destroyed when it goes out
-  // of scope.  The finished proxy will be returned in the slot by calling
-  // create_finish().
-  Glib::RefPtr<DBusProxy>(new DBusProxy(connection, name, object_path,
-    interface_name, slot, cancellable, info, flags))->reference();
+  DBusProxy(connection, name, object_path, interface_name, slot,
+    cancellable, info, flags);
 }
 
 void DBusProxy::create(const Glib::RefPtr<DBusConnection>& connection,
@@ -195,12 +191,7 @@ void DBusProxy::create(const Glib::RefPtr<DBusConnection>& connection,
   const Glib::RefPtr<DBusInterfaceInfo>& info,
   DBusProxyFlags flags)
 {
-  // Create the proxy, taking an extra reference without returning it.  The
-  // extra reference is taken so the proxy is not destroyed when it goes out
-  // of scope.  The finished proxy will be returned in the slot by calling
-  // create_finish().
-  Glib::RefPtr<DBusProxy>(new DBusProxy(connection, name, object_path,
-    interface_name, slot, info, flags))->reference();
+  DBusProxy(connection, name, object_path, interface_name, slot, info, flags);
 }
 
 Glib::RefPtr<DBusProxy>
@@ -237,12 +228,8 @@ void DBusProxy::create_for_bus(BusType bus_type,
   const Glib::RefPtr<DBusInterfaceInfo>& info,
   DBusProxyFlags flags)
 {
-  // Create the proxy, taking an extra reference without returning it.  The
-  // extra reference is taken so the proxy is not destroyed when it goes out
-  // of scope.  The finished proxy will be returned in the slot by calling
-  // create_finish().
-  Glib::RefPtr<DBusProxy>(new DBusProxy(bus_type, name, object_path,
-    interface_name, slot, cancellable, info, flags))->reference();
+  DBusProxy(bus_type, name, object_path, interface_name, slot, cancellable,
+    info, flags);
 }
 
 void DBusProxy::create_for_bus(BusType bus_type,
@@ -253,12 +240,7 @@ void DBusProxy::create_for_bus(BusType bus_type,
   const Glib::RefPtr<DBusInterfaceInfo>& info,
   DBusProxyFlags flags)
 {
-  // Create the proxy, taking an extra reference without returning it.  The
-  // extra reference is taken so the proxy is not destroyed when it goes out
-  // of scope.  The finished proxy will be returned in the slot by calling
-  // create_finish().
-  Glib::RefPtr<DBusProxy>(new DBusProxy(bus_type, name, object_path,
-    interface_name, slot, info, flags))->reference();
+  DBusProxy(bus_type, name, object_path, interface_name, slot, info, flags);
 }
 
 Glib::RefPtr<DBusProxy> DBusProxy::create_for_bus_sync(BusType bus_type,



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