kbrown / rpms / libreoffice

Forked from rpms/libreoffice 2 years ago
Clone

Blame SOURCES/0001-rhbz-1016758-Dispose-bridges-when-disposing-bridge-f.patch

f085be
From bf3ebcc6aae09d233df6632e72cf06b1d9256692 Mon Sep 17 00:00:00 2001
f085be
From: Stephan Bergmann <sbergman@redhat.com>
f085be
Date: Mon, 19 May 2014 18:06:16 +0200
f085be
Subject: [PATCH] rhbz#1016758: Dispose bridges when disposing bridge factory
f085be
f085be
... (which happens when the service manager is disposed), so that no bridges can
f085be
still run during exit.  But this is so glaring that I wonder whether I missed
f085be
the obvious when I originally wrote that code, or whether I rather miss the
f085be
obvious now.  So better let this rest for a while on master before deciding
f085be
about any backports.
f085be
f085be
(cherry picked from commit 184e4ef35641403fd293262ee413ceee37b3761a)
f085be
Conflicts:
f085be
	binaryurp/source/bridgefactory.cxx
f085be
f085be
Change-Id: I7c9ad6c8a53dfd1a7b702640920dcb0a9a2c3007
f085be
---
f085be
 binaryurp/source/bridgefactory.cxx | 31 +++++++++++++++++++++++++++++++
f085be
 binaryurp/source/bridgefactory.hxx |  2 ++
f085be
 2 files changed, 33 insertions(+)
f085be
f085be
diff --git a/binaryurp/source/bridgefactory.cxx b/binaryurp/source/bridgefactory.cxx
f085be
index 34182b3..6f13614 100644
f085be
--- a/binaryurp/source/bridgefactory.cxx
f085be
+++ b/binaryurp/source/bridgefactory.cxx
f085be
@@ -115,6 +115,11 @@ css::uno::Reference< css::bridge::XBridge > BridgeFactory::createBridge(
f085be
     rtl::Reference< Bridge > b;
f085be
     {
f085be
         osl::MutexGuard g(*this);
f085be
+        if (rBHelper.bDisposed) {
f085be
+            throw css::lang::DisposedException(
f085be
+                "BridgeFactory disposed",
f085be
+                static_cast< cppu::OWeakObject * >(this));
f085be
+        }
f085be
         if (named_.find(sName) != named_.end()) {
f085be
             throw css::bridge::BridgeExistsException(
f085be
                 sName, static_cast< cppu::OWeakObject * >(this));
f085be
@@ -172,6 +177,32 @@ BridgeFactory::getExistingBridges() throw (css::uno::RuntimeException) {
f085be
     return s;
f085be
 }
f085be
 
f085be
+void BridgeFactory::disposing() {
f085be
+    BridgeList l1;
f085be
+    BridgeMap l2;
f085be
+    {
f085be
+        osl::MutexGuard g(*this);
f085be
+        l1.swap(unnamed_);
f085be
+        l2.swap(named_);
f085be
+    }
f085be
+    for (BridgeList::iterator i(l1.begin()); i != l1.end(); ++i) {
f085be
+        try {
f085be
+            css::uno::Reference<css::lang::XComponent>(
f085be
+                *i, css::uno::UNO_QUERY_THROW)->dispose();
f085be
+        } catch (css::uno::Exception & e) {
f085be
+            SAL_WARN("binaryurp", "ignoring Exception " << e.Message);
f085be
+        }
f085be
+    }
f085be
+    for (BridgeMap::iterator i(l2.begin()); i != l2.end(); ++i) {
f085be
+        try {
f085be
+            css::uno::Reference<css::lang::XComponent>(
f085be
+                i->second, css::uno::UNO_QUERY_THROW)->dispose();
f085be
+        } catch (css::uno::Exception & e) {
f085be
+            SAL_WARN("binaryurp", "ignoring Exception " << e.Message);
f085be
+        }
f085be
+    }
f085be
+}
f085be
+
f085be
 }
f085be
 
f085be
 namespace {
f085be
diff --git a/binaryurp/source/bridgefactory.hxx b/binaryurp/source/bridgefactory.hxx
f085be
index a949e63..98f1ab2 100644
f085be
--- a/binaryurp/source/bridgefactory.hxx
f085be
+++ b/binaryurp/source/bridgefactory.hxx
f085be
@@ -114,6 +114,8 @@ private:
f085be
         com::sun::star::uno::Reference< com::sun::star::bridge::XBridge > >
f085be
     SAL_CALL getExistingBridges() throw (com::sun::star::uno::RuntimeException);
f085be
 
f085be
+    void SAL_CALL disposing() SAL_OVERRIDE;
f085be
+
f085be
     typedef
f085be
         std::list<
f085be
             com::sun::star::uno::Reference< com::sun::star::bridge::XBridge > >
f085be
-- 
f085be
1.9.3
f085be