summaryrefslogtreecommitdiff
path: root/sw/source/uibase/uno/unoatxt.cxx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-01-04 11:58:19 +0100
committerStephan Bergmann <sbergman@redhat.com>2017-01-04 12:11:20 +0100
commit1677faabbf7ae56e233205251b78b77d28937c35 (patch)
tree9ae0df17a5d43edbc471c0167c0116e84423cc42 /sw/source/uibase/uno/unoatxt.cxx
parent49f3dc55dd4a425a45fdd2b86d285e616559f366 (diff)
SwXAutoTextEntry needs a disposal protocol
SwXAutoTextEntry::GetBodyText calls SwGlossaries::EditGroupDoc to create a Sw[Web]GlosDocShell (which it then stores in xDocSh), and there must be a call to that shell's DoClose to clean up its resources. However, if a reference to the SwXAutoTextEntry is still held during XDesktop::terminate (as can happen in JunitTest_sw_unoapi_1, where such a reference is held from Java, thus arbitrarily delaying destruction of the SwXAutoTextEntry until the JVM does GC), SwXAutoTextEntry::Notify's PrepareCloseDoc case will release xDocSh without calling DoClose, so an eventual ~SwXAutoTextEntry will not call DoClose either. (And calling DoClose from withing SwXAutoTextEntry::Notify would cause a crash, as it would destroy the SwGlosDocShell recursively from within its SfxBroadcaster::Broadcast call.) So introduce a disposal protocol for XAutoTextEntry and call it at least in the place that caused the resource leak in JunitTest_sw_unoapi_1. For lack of a better inerface, reuse css.lang.XComponent for that protocol, even though this scenario doesn't involve breaking cyclic references among UNO objects caused by listener patterns. Change-Id: Id6501b84e562950e40b83e0b1afd1b3184807856
Diffstat (limited to 'sw/source/uibase/uno/unoatxt.cxx')
-rw-r--r--sw/source/uibase/uno/unoatxt.cxx7
1 files changed, 7 insertions, 0 deletions
diff --git a/sw/source/uibase/uno/unoatxt.cxx b/sw/source/uibase/uno/unoatxt.cxx
index f984a3e65428..ef41ed8649aa 100644
--- a/sw/source/uibase/uno/unoatxt.cxx
+++ b/sw/source/uibase/uno/unoatxt.cxx
@@ -718,6 +718,7 @@ sal_Int64 SAL_CALL SwXAutoTextEntry::getSomething( const uno::Sequence< sal_Int8
SwXAutoTextEntry::SwXAutoTextEntry(SwGlossaries* pGlss, const OUString& rGroupName,
const OUString& rEntryName) :
+ WeakComponentImplHelper(m_aMutex),
pGlossaries(pGlss),
sGroupName(rGroupName),
sEntryName(rEntryName),
@@ -801,6 +802,12 @@ void SwXAutoTextEntry::GetBodyText ()
xBodyText.set( *pBodyText, uno::UNO_QUERY);
}
+void SwXAutoTextEntry::disposing()
+{
+ SolarMutexGuard g;
+ implFlushDocument(true);
+}
+
uno::Reference< text::XTextCursor > SwXAutoTextEntry::createTextCursor() throw( uno::RuntimeException, std::exception )
{
SolarMutexGuard aGuard;