From 4cacc6080e61374fd573fffb3bc2a54968c1b61a Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Thu, 15 May 2014 12:19:27 +0200 Subject: Make sure to dispose services supporting the XComponent protocol ...to e.g. avoid leftover temp files from instantiating com.sun.star.comp.report.OReportDefinition. But dispose all instances only at the very end, to avoid disposing some single-instance services too early. Change-Id: I71fc50e80f4b5d1a1ca16e392725903b079ce2d1 --- postprocess/qa/services.cxx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'postprocess/qa') diff --git a/postprocess/qa/services.cxx b/postprocess/qa/services.cxx index c9d30f4f1031..2d29e918a420 100644 --- a/postprocess/qa/services.cxx +++ b/postprocess/qa/services.cxx @@ -9,7 +9,10 @@ #include +#include + #include +#include #include #include #include @@ -37,6 +40,7 @@ void ServicesTest::test() "/singletons/com.sun.star.reflection.theTypeDescriptionManager"), UNO_QUERY_THROW ); Sequence s = m_xContext->getServiceManager()->getAvailableServiceNames(); + std::vector< css::uno::Reference > comps; for (sal_Int32 i = 0; i < s.getLength(); i++) { if (!xTypeManager->hasByHierarchicalName(s[i])) @@ -54,12 +58,13 @@ void ServicesTest::test() Sequence< Reference< XServiceConstructorDescription > > xseq = xDesc->getConstructors(); for (sal_Int32 c = 0; c < xseq.getLength(); c++) if (!xseq[c]->getParameters().hasElements()) + { + Reference< XInterface > instance; try { OString message = OUStringToOString(s[i], RTL_TEXTENCODING_UTF8); bool bDefConstructor = xseq[c]->isDefaultConstructor(); Reference< css::lang::XMultiComponentFactory > serviceManager = m_xContext->getServiceManager(); - Reference< XInterface > instance; if( bDefConstructor ) instance = serviceManager->createInstanceWithContext(s[i], m_xContext); @@ -75,6 +80,18 @@ void ServicesTest::test() OUStringToOString(s[i] + ": " + e.Message, RTL_TEXTENCODING_UTF8); CPPUNIT_FAIL(exc.getStr()); } + css::uno::Reference comp( + instance, css::uno::UNO_QUERY); + if (comp.is()) { + comps.push_back(comp); + } + } + } + for (std::vector< css::uno::Reference >::iterator i( + comps.begin()); + i != comps.end(); ++i) + { + (*i)->dispose(); } } -- cgit