diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2008-07-15 19:21:51 +0100 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2008-07-15 19:21:51 +0100 |
commit | 2f7e3865c5cae60769b98dac163802e224345fb9 (patch) | |
tree | ae6484c3ddb24107935aee73c4cd17d7a269cec1 | |
parent | bdc76e63da5ca9e017cfbea6c1ce1b0e21ebf706 (diff) | |
download | dbus-python-2f7e3865c5cae60769b98dac163802e224345fb9.tar.gz |
DbusPyServer: construct connections by calling the type, so the object will be fully initialized
-rw-r--r-- | _dbus_bindings/server.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/_dbus_bindings/server.c b/_dbus_bindings/server.c index a7295a6..7fc4f70 100644 --- a/_dbus_bindings/server.c +++ b/_dbus_bindings/server.c @@ -162,8 +162,8 @@ DBusPyServer_new_connection_cb(DBusServer *server, void *data UNUSED) { PyGILState_STATE gil = PyGILState_Ensure(); - PyObject *self = NULL, *conn_obj = NULL; - PyObject *method = NULL, *result = NULL; + PyObject *self = NULL; + PyObject *method = NULL; self = DBusPyServer_ExistingFromDBusServer(server); if (!self) goto out; @@ -173,18 +173,30 @@ DBusPyServer_new_connection_cb(DBusServer *server, TRACE(method); if (method) { - conn_obj = DBusPyConnection_NewConsumingDBusConnection( - ((Server *) self)->conn_class, - dbus_connection_ref(conn), - ((Server*) self)->mainloop); + PyObject *conn_class = ((Server *)self)->conn_class; + PyObject *wrapper = DBusPyLibDBusConnection_New(conn); + PyObject *conn_obj; + PyObject *result; + + if (!wrapper) + goto out; + + conn_obj = PyObject_CallFunctionObjArgs((PyObject *)conn_class, + wrapper, ((Server*) self)->mainloop, NULL); + Py_DECREF(wrapper); + + if (!conn_obj) + goto out; result = PyObject_CallFunctionObjArgs(method, conn_obj, NULL); + Py_XDECREF (conn_obj); + + /* discard result if not NULL, and fall through regardless */ + Py_XDECREF(result); } out: - Py_XDECREF(result); Py_XDECREF(method); - Py_XDECREF(conn_obj); Py_XDECREF(self); if (PyErr_Occurred()) |