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