summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-07-27 11:06:41 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-07-30 10:49:27 +0200
commit6e35794cad555485955c3b43593497dcdbf29840 (patch)
tree430c0299f21fb62faf6d0ba5e04410fafdda14d2 /test
parenta6e02f6337f038a445b858bb91bf14d1a14768e4 (diff)
terminate XDesktop properly in unit tests
So that the UNO constructor work can continue - where we need the desktop to be disposed properly so that all UNO constructors objects have their dispose() called, and they can clean up their global state. We detect this case by changing a SAL_WARN to an assert in Desktop::disposing() (*) in ~ScTabViewShell, don't call EnterHandler, because that tries to create EditEngine's and other stuff, which crashes (*) Need a fake singleton so that the servicemanager calls dispose() on the AnalysAddIn and we can clear the global variable there. Change-Id: Id13b51e17afc16fcbbc65d64281cdf847e4a58cf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99640 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'test')
-rw-r--r--test/source/setupvcl.cxx39
1 files changed, 27 insertions, 12 deletions
diff --git a/test/source/setupvcl.cxx b/test/source/setupvcl.cxx
index 56c0a3b3c84c..7e489effb307 100644
--- a/test/source/setupvcl.cxx
+++ b/test/source/setupvcl.cxx
@@ -12,6 +12,7 @@
#include <com/sun/star/configuration/theDefaultProvider.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/util/XFlushable.hpp>
+#include <com/sun/star/frame/Desktop.hpp>
#include <comphelper/processfactory.hxx>
#include <i18nlangtag/languagetag.hxx>
#include <i18nlangtag/mslangid.hxx>
@@ -37,20 +38,34 @@ IMPL_STATIC_LINK_NOARG(Hook, deinitHook, LinkParamNone *, void) {
try {
context = comphelper::getProcessComponentContext();
} catch (css::uno::RuntimeException &) {}
- if (context.is()) {
- css::uno::Reference<css::lang::XMultiServiceFactory> config;
+
+ if (!context)
+ return;
+
+ css::uno::Reference<css::lang::XMultiServiceFactory> config;
+ try {
+ config = css::configuration::theDefaultProvider::get(context);
+ } catch (css::uno::DeploymentException &) {}
+ if (config) {
+ utl::ConfigManager::storeConfigItems();
+ css::uno::Reference<css::util::XFlushable>(
+ config, css::uno::UNO_QUERY_THROW)->flush();
+ }
+
+ // the desktop has to be terminate() before it can be dispose()
+ css::uno::Reference<css::frame::XDesktop> xDesktop;
+ try {
+ xDesktop = css::frame::Desktop::create(comphelper::getProcessComponentContext());
+ } catch (css::uno::DeploymentException &) {}
+ if (xDesktop)
try {
- config = css::configuration::theDefaultProvider::get(context);
+ xDesktop->terminate();
} catch (css::uno::DeploymentException &) {}
- if (config.is()) {
- utl::ConfigManager::storeConfigItems();
- css::uno::Reference<css::util::XFlushable>(
- config, css::uno::UNO_QUERY_THROW)->flush();
- }
- css::uno::Reference<css::lang::XComponent>(
- context, css::uno::UNO_QUERY_THROW)->dispose();
- comphelper::setProcessServiceFactory(nullptr);
- }
+
+ css::uno::Reference<css::lang::XComponent>(
+ context, css::uno::UNO_QUERY_THROW)->dispose();
+
+ comphelper::setProcessServiceFactory(nullptr);
}
}