diff --git a/include/dbus-c++/message.h b/include/dbus-c++/message.h index 2d132bb..a287ab8 100644 --- a/include/dbus-c++/message.h +++ b/include/dbus-c++/message.h @@ -164,7 +164,7 @@ public: struct Private; - Message( Private* ); + Message( Private*, bool incref = true ); Message( const Message& m ); diff --git a/src/connection.cpp b/src/connection.cpp index e961d0d..bf43a99 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -350,7 +350,7 @@ Message Connection::send_blocking( Message& msg, int timeout ) if(e) throw Error(e); - return Message(new Message::Private(reply)); + return Message(new Message::Private(reply), false); } PendingCall Connection::send_async( Message& msg, int timeout ) diff --git a/src/message.cpp b/src/message.cpp index 41ccef7..6f6d7af 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -365,10 +365,10 @@ Message::Message() { } -Message::Message( Message::Private* p ) +Message::Message( Message::Private* p, bool incref ) : _pvt(p) { - if(_pvt->msg) dbus_message_ref(_pvt->msg); + if(_pvt->msg && incref) dbus_message_ref(_pvt->msg); } Message::Message( const Message& m )