From 5269fc0e04984b2d196d5eaf96e206e034d21184 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Fri, 20 Aug 2010 13:58:20 +0000 Subject: QPID-2798 - C++ Messaging Client .NET binding fails to clone managed objects correctly Patch from Chuck Rolke git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@987510 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/bindings/qpid/dotnet/src/Connection.cpp | 39 +++++------------------------ 1 file changed, 6 insertions(+), 33 deletions(-) (limited to 'cpp/bindings/qpid/dotnet/src/Connection.cpp') diff --git a/cpp/bindings/qpid/dotnet/src/Connection.cpp b/cpp/bindings/qpid/dotnet/src/Connection.cpp index 50755302f3..322910d820 100644 --- a/cpp/bindings/qpid/dotnet/src/Connection.cpp +++ b/cpp/bindings/qpid/dotnet/src/Connection.cpp @@ -132,16 +132,13 @@ namespace Messaging { Session ^ Connection::CreateTransactionalSession(System::String ^ name) { System::Exception ^ newException = nullptr; - ::qpid::messaging::Session * sessionp = NULL; Session ^ newSession = nullptr; try { - // allocate native session - sessionp = new ::qpid::messaging::Session ; - // create native session - *sessionp = connectionp->createTransactionalSession(QpidMarshal::ToNative(name)); + ::qpid::messaging::Session sessionp = + connectionp->createTransactionalSession(QpidMarshal::ToNative(name)); // create managed session newSession = gcnew Session(sessionp, this); @@ -160,13 +157,6 @@ namespace Messaging { { delete newSession; } - else - { - if (sessionp != NULL) - { - delete sessionp; - } - } } } @@ -191,16 +181,13 @@ namespace Messaging { Session ^ Connection::CreateSession(System::String ^ name) { System::Exception ^ newException = nullptr; - ::qpid::messaging::Session * sessionp = NULL; Session ^ newSession = nullptr; try { - // allocate native session - sessionp = new ::qpid::messaging::Session ; - // create native session - *sessionp = connectionp->createSession(QpidMarshal::ToNative(name)); + ::qpid::messaging::Session sessionp = + connectionp->createSession(QpidMarshal::ToNative(name)); // create managed session newSession = gcnew Session(sessionp, this); @@ -219,13 +206,6 @@ namespace Messaging { { delete newSession; } - else - { - if (sessionp != NULL) - { - delete sessionp; - } - } } } @@ -241,14 +221,14 @@ namespace Messaging { Session ^ Connection::GetSession(System::String ^ name) { System::Exception ^ newException = nullptr; - ::qpid::messaging::Session * sess = NULL; Session ^ newSession = nullptr; try { const std::string n = QpidMarshal::ToNative(name); - *sess = connectionp->::qpid::messaging::Connection::getSession(n); + ::qpid::messaging::Session sess = + connectionp->::qpid::messaging::Connection::getSession(n); newSession = gcnew Session(sess, this); } @@ -266,13 +246,6 @@ namespace Messaging { { delete newSession; } - else - { - if (sess != NULL) - { - delete sess; - } - } } } -- cgit v1.2.1