[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - cli_ure/source
Michael Stahl
mstahl at redhat.com
Thu Aug 28 08:54:45 PDT 2014
cli_ure/source/uno_bridge/cli_environment.cxx | 8 ++++++--
cli_ure/source/uno_bridge/cli_environment.h | 1 +
cli_ure/source/uno_bridge/cli_proxy.cxx | 16 +++++++++++++---
cli_ure/source/uno_bridge/cli_proxy.h | 3 +++
4 files changed, 23 insertions(+), 5 deletions(-)
New commits:
commit 266a9536b5abf4c36fed1785ae657da923bbbb8d
Author: Michael Stahl <mstahl at redhat.com>
Date: Tue Aug 26 23:49:47 2014 +0200
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 at redhat.com>
Tested-by: Michael Stahl <mstahl at redhat.com>
(cherry picked from commit 25df8adbc0e753fa227e5e170d98c722c4553f32)
Reviewed-on: https://gerrit.libreoffice.org/11174
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
Tested-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/cli_ure/source/uno_bridge/cli_environment.cxx b/cli_ure/source/uno_bridge/cli_environment.cxx
index 826b56e..0bcf88a 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 0a0b251..41e1166 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 86e5078..c5734c1 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 093b674..b92cf77 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();
/**
*/
More information about the Libreoffice-commits
mailing list