]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
* python/dbus_bindings.pyx: Tracked down a major memleak and fixed it
authorJohn (J5) Palmieri <johnp@redhat.com>
Fri, 26 Aug 2005 03:09:59 +0000 (03:09 +0000)
committerJohn (J5) Palmieri <johnp@redhat.com>
Fri, 26 Aug 2005 03:09:59 +0000 (03:09 +0000)
 (EmptyMessage): new class that subclasses Message.  This is a workaround
 to a Pyrex bug that fails to call __del__ when the Message object goes out
 of scope.  For some reason subclassing Message fixes this bug
 (Bus::send_with_reply_and_block): use EmptyMessage instead of Message

ChangeLog
python/dbus_bindings.pyx
python/proxies.py

index 0d591f80fa1165447e4a712a877ceb84857c6f61..165842eccea1361455fd4b104575be390cda958e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2005-08-25  John (J5) Palmieri  <johnp@redhat.com>
+
+       * python/dbus_bindings.pyx: Tracked down a major memleak and fixed it
+       (EmptyMessage): new class that subclasses Message.  This is a workaround
+       to a Pyrex bug that fails to call __del__ when the Message object goes out
+       of scope.  For some reason subclassing Message fixes this bug
+       (Bus::send_with_reply_and_block): use EmptyMessage instead of Message
+
 2005-08-25  Colin Walters  <walters@verbum.org>
 
        * glib/dbus-gproxy.c (dbus_g_proxy_call): Doc update, thanks
index a083f504bdc4494118798f146d77a487d6917cec..93a9473361e50e0b4d57713e79c5ad9d5db5cf5c 100644 (file)
@@ -359,7 +359,7 @@ cdef class Connection:
         return (retval, pending_call)
                                 
     def send_with_reply_and_block(self, Message message,
-                                  timeout_milliseconds=0):
+                                  timeout_milliseconds=-1):
         cdef DBusMessage * retval
         cdef DBusError error
         cdef DBusMessage *msg
@@ -381,9 +381,10 @@ cdef class Connection:
         if retval == NULL:
             raise AssertionError
         
-        m = Message(_create=0)
+        m = EmptyMessage()
         m._set_msg(retval)
-        return m
+
+        return m 
 
     def set_watch_functions(self, add_function, remove_function, data):
         pass
@@ -1255,19 +1256,18 @@ cdef class Message:
         if (service != None):
             cservice = service
             
-        if not _create:
-            return
-
-        if message_type == MESSAGE_TYPE_METHOD_CALL:
-            self.msg = dbus_message_new_method_call(cservice, path, ciface, method)
-        elif message_type == MESSAGE_TYPE_METHOD_RETURN:
-            cmsg = method_call._get_msg()
-            self.msg = dbus_message_new_method_return(cmsg)
-        elif message_type == MESSAGE_TYPE_SIGNAL:
-            self.msg = dbus_message_new_signal(path, ciface, name)
-        elif message_type == MESSAGE_TYPE_ERROR:
-            cmsg = reply_to._get_msg()
-            self.msg = dbus_message_new_error(cmsg, error_name, error_message)
+        if _create:
+            if message_type == MESSAGE_TYPE_METHOD_CALL:
+                self.msg = dbus_message_new_method_call(cservice, path, ciface, method)
+            elif message_type == MESSAGE_TYPE_METHOD_RETURN:
+                cmsg = method_call._get_msg()
+                self.msg = dbus_message_new_method_return(cmsg)
+            elif message_type == MESSAGE_TYPE_SIGNAL:
+                self.msg = dbus_message_new_signal(path, ciface, name)
+            elif message_type == MESSAGE_TYPE_ERROR:
+                cmsg = reply_to._get_msg()
+                self.msg = dbus_message_new_error(cmsg, error_name, error_message)
 
     def __del__(self):
         if self.msg != NULL:
@@ -1439,6 +1439,10 @@ class Signal(Message):
     def __init__(self, spath, sinterface, sname):
         Message.__init__(self, MESSAGE_TYPE_SIGNAL, path=spath, dbus_interface=sinterface, name=sname)
 
+class EmptyMessage(Message):
+    def __init__(self):
+        Message.__init__(self, _create=False)
+
 class MethodCall(Message):
     def __init__(self, mpath, minterface, mmethod):
         Message.__init__(self, MESSAGE_TYPE_METHOD_CALL, path=mpath, dbus_interface=minterface, method=mmethod)
index 428664263e558d5820bd20131b94bb36b29ce3c6..f41a8de1e14f5d23ea9d2629e6b5bffcf1959dfa 100644 (file)
@@ -63,7 +63,7 @@ class ProxyMethod:
         else:
             reply_message = self._connection.send_with_reply_and_block(message, timeout)
             args_tuple = reply_message.get_args_list()
-            
+
         if len(args_tuple) == 0:
             return
         elif len(args_tuple) == 1: