diff options
author | Michael Stahl <mstahl@redhat.com> | 2014-08-26 23:49:47 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2014-08-27 05:06:32 -0500 |
commit | 25df8adbc0e753fa227e5e170d98c722c4553f32 (patch) | |
tree | bdaead478576ca372959acbbec672eed9ead2a88 | |
parent | 64c187b8628bc103383f3c525d1debef5e32ad2e (diff) |
cli_ure: adapt destructors in cli_uno library to "C++/CLI"
commit 4b56d82c7d20ba5897d87aaf7fc94da5356b8eec converted the cli_uno
library from "Managed C++" to "C++/CLI", but forgot one detail:
The destructors on "ref" classes were mapped to Finalize() methods in
the old syntax, but the new one maps them to Dispose() methods, which
are only invoked on stack-allocated objects. Presumably this omission
results in leaking of native C++ UNO objects.
Reading the C++/CLI documentation i get the impression that:
1) the destructor should explicitly call the finalizer
2) the CLR will not call the finalizer itself iff the destructor is
invoked
http://msdn.microsoft.com/en-us/library/ms235315.aspx
http://msdn.microsoft.com/en-us/library/ke3a209d%28v=vs.110%29.aspx
Change-Id: I509d9b69a399c3d7d6597060ab9b7c78c5916e11
Reviewed-on: https://gerrit.libreoffice.org/11132
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Tested-by: Michael Stahl <mstahl@redhat.com>
-rw-r--r-- | cli_ure/source/uno_bridge/cli_environment.cxx | 8 | ||||
-rw-r--r-- | cli_ure/source/uno_bridge/cli_environment.h | 1 | ||||
-rw-r--r-- | cli_ure/source/uno_bridge/cli_proxy.cxx | 16 | ||||
-rw-r--r-- | cli_ure/source/uno_bridge/cli_proxy.h | 3 |
4 files changed, 23 insertions, 5 deletions
diff --git a/cli_ure/source/uno_bridge/cli_environment.cxx b/cli_ure/source/uno_bridge/cli_environment.cxx index 826b56e015d6..0bcf88a40699 100644 --- a/cli_ure/source/uno_bridge/cli_environment.cxx +++ b/cli_ure/source/uno_bridge/cli_environment.cxx @@ -47,13 +47,17 @@ inline Cli_environment::Cli_environment() #endif } -Cli_environment::~Cli_environment() +Cli_environment::~Cli_environment() ///< IDisposable Cli_environment::Dispose() +{ + this->!Cli_environment(); // call finalizer +} + +Cli_environment::!Cli_environment() ///< Cli_environment::Finalize() { OSL_ENSURE(_numRegisteredObjects == 0, "cli uno bridge: CLI environment contains unrevoked objects"); } - System::Object^ Cli_environment::registerInterface( System::Object^ obj, System::String^ oid) { diff --git a/cli_ure/source/uno_bridge/cli_environment.h b/cli_ure/source/uno_bridge/cli_environment.h index 0a0b251aa452..41e1166494d6 100644 --- a/cli_ure/source/uno_bridge/cli_environment.h +++ b/cli_ure/source/uno_bridge/cli_environment.h @@ -56,6 +56,7 @@ public: inline Cli_environment(); ~Cli_environment(); + !Cli_environment(); /** Registers an UNO object as being mapped by this bridge. The resulting diff --git a/cli_ure/source/uno_bridge/cli_proxy.cxx b/cli_ure/source/uno_bridge/cli_proxy.cxx index 86e5078db376..c5734c1af935 100644 --- a/cli_ure/source/uno_bridge/cli_proxy.cxx +++ b/cli_ure/source/uno_bridge/cli_proxy.cxx @@ -87,7 +87,13 @@ UnoInterfaceInfo::UnoInterfaceInfo(Bridge const * bridge, uno_Interface* unoI, } } } -UnoInterfaceInfo::~UnoInterfaceInfo() + +UnoInterfaceInfo::~UnoInterfaceInfo() ///< IDisposable UnoInterfaceInfo::Dispose() +{ + this->!UnoInterfaceInfo(); // call finalizer +} + +UnoInterfaceInfo::!UnoInterfaceInfo() ///< UnoInterfaceInfo::Finalize() { //accessing unmanaged objects is ok. m_bridge->m_uno_env->revokeInterface( @@ -124,7 +130,12 @@ UnoInterfaceProxy::UnoInterfaceProxy( } -UnoInterfaceProxy::~UnoInterfaceProxy() +UnoInterfaceProxy::~UnoInterfaceProxy() ///< IDisposable UnoInterfaceProxy::Dispose() +{ + this->!UnoInterfaceProxy(); // call finalizer +} + +UnoInterfaceProxy::!UnoInterfaceProxy() ///< UnoInterfaceProxy::Finalize() { #if OSL_DEBUG_LEVEL >= 2 sd::Trace::WriteLine(System::String::Format( @@ -140,7 +151,6 @@ UnoInterfaceProxy::~UnoInterfaceProxy() m_bridge->release(); } - System::Object^ UnoInterfaceProxy::create( Bridge * bridge, uno_Interface * pUnoI, diff --git a/cli_ure/source/uno_bridge/cli_proxy.h b/cli_ure/source/uno_bridge/cli_proxy.h index feb1ad4c4a74..32ffd571d2e1 100644 --- a/cli_ure/source/uno_bridge/cli_proxy.h +++ b/cli_ure/source/uno_bridge/cli_proxy.h @@ -46,6 +46,8 @@ public: UnoInterfaceInfo(Bridge const * bridge, uno_Interface* unoI, typelib_InterfaceTypeDescription* td); ~UnoInterfaceInfo(); + !UnoInterfaceInfo(); + uno_Interface * m_unoI; // wrapped interface System::Type ^ m_type; typelib_InterfaceTypeDescription* m_typeDesc; @@ -112,6 +114,7 @@ public: void addUnoInterface(uno_Interface* pUnoI, typelib_InterfaceTypeDescription* pTd); ~UnoInterfaceProxy(); + !UnoInterfaceProxy(); /** */ |