[Libreoffice-commits] .: Branch 'libreoffice-3-6' - desktop/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Dec 7 05:03:22 PST 2012
desktop/source/deployment/gui/dp_gui_service.cxx | 16 ++++++++
desktop/source/deployment/inc/dp_misc.h | 8 ++++
desktop/source/deployment/misc/dp_misc.cxx | 25 +++++++++++++
desktop/source/pkgchk/unopkg/unopkg_app.cxx | 42 ++---------------------
desktop/source/pkgchk/unopkg/unopkg_misc.cxx | 15 +-------
desktop/source/pkgchk/unopkg/unopkg_shared.h | 32 -----------------
6 files changed, 57 insertions(+), 81 deletions(-)
New commits:
commit 547a3d8f98d0b3db0e0553edcab760b3a80ede51
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Tue Oct 30 17:11:59 2012 +0100
Resolves: fdo#51638 In "unopkg gui" dispose component context from DeInitVCL
...the same way it is done in soffice.bin. framework's Desktop::dispose()
requires the solar mutex to be still alive, which is destroyed in DeInitVCL, so
if the component context/service manager is only disposed afterwards, the solar
mutex is already gone.
This required moving disposeBridges() around, but it allowed to get rid of
DisposeGuard.
(cherry picked from commit 37cc83e594fa8ca131fc5fb98506287b7daedffd)
Conflicts:
desktop/source/pkgchk/unopkg/unopkg_app.cxx
desktop/source/pkgchk/unopkg/unopkg_shared.h
Change-Id: Ibec3d19040fdae23f492cd1e29084e673403e00b
Signed-off-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/desktop/source/deployment/gui/dp_gui_service.cxx b/desktop/source/deployment/gui/dp_gui_service.cxx
index 71c6ccd..cec91ad 100644
--- a/desktop/source/deployment/gui/dp_gui_service.cxx
+++ b/desktop/source/deployment/gui/dp_gui_service.cxx
@@ -33,6 +33,7 @@
#include "cppuhelper/implbase2.hxx"
#include "cppuhelper/implementationentry.hxx"
#include "unotools/configmgr.hxx"
+#include "comphelper/processfactory.hxx"
#include "comphelper/servicedecl.hxx"
#include "comphelper/unwrapargs.hxx"
#include <i18npool/mslangid.hxx>
@@ -47,6 +48,8 @@
#include "license_dialog.hxx"
#include "dp_gui_dialog2.hxx"
#include "dp_gui_extensioncmdqueue.hxx"
+#include <ucbhelper/contentbroker.hxx>
+
using namespace ::dp_misc;
using namespace ::com::sun::star;
@@ -66,6 +69,7 @@ public:
// Application
virtual int Main();
+ virtual void DeInit();
};
//______________________________________________________________________________
@@ -85,6 +89,18 @@ int MyApp::Main()
}
+void MyApp::DeInit()
+{
+ if (::ucbhelper::ContentBroker::get())
+ ::ucbhelper::ContentBroker::deinitialize();
+ css::uno::Reference< css::uno::XComponentContext > context(
+ comphelper::getProcessComponentContext());
+ dp_misc::disposeBridges(context);
+ css::uno::Reference< css::lang::XComponent >(
+ context, css::uno::UNO_QUERY_THROW)->dispose();
+ comphelper::setProcessServiceFactory(0);
+}
+
namespace
{
struct ProductName
diff --git a/desktop/source/deployment/inc/dp_misc.h b/desktop/source/deployment/inc/dp_misc.h
index 06e67aa..b95a64c 100644
--- a/desktop/source/deployment/inc/dp_misc.h
+++ b/desktop/source/deployment/inc/dp_misc.h
@@ -159,6 +159,14 @@ void syncRepositories(
::com::sun::star::uno::Reference<
::com::sun::star::ucb::XCommandEnvironment> const & xCmdEnv);
+/** workaround: for some reason the bridge threads which communicate with the
+ uno.exe process are not released on time
+*/
+DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
+void disposeBridges(
+ com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
+ const & ctx);
+
}
#endif
diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx
index 9ed579f..00fd352 100644
--- a/desktop/source/deployment/misc/dp_misc.cxx
+++ b/desktop/source/deployment/misc/dp_misc.cxx
@@ -43,6 +43,7 @@
#include "osl/mutex.hxx"
#include "com/sun/star/ucb/CommandAbortedException.hpp"
#include "com/sun/star/task/XInteractionHandler.hpp"
+#include "com/sun/star/bridge/XBridgeFactory.hpp"
#include "com/sun/star/bridge/UnoUrlResolver.hpp"
#include "com/sun/star/bridge/XUnoUrlResolver.hpp"
#include "com/sun/star/deployment/ExtensionManager.hpp"
@@ -631,7 +632,31 @@ void syncRepositories(
}
}
+void disposeBridges(Reference<css::uno::XComponentContext> const & ctx)
+{
+ if (!ctx.is())
+ return;
+ Reference<css::bridge::XBridgeFactory> bridgeFac(
+ ctx->getServiceManager()->createInstanceWithContext(
+ OUSTR("com.sun.star.bridge.BridgeFactory"), ctx),
+ UNO_QUERY_THROW);
+
+ const Sequence< Reference<css::bridge::XBridge> >seqBridges = bridgeFac->getExistingBridges();
+ for (sal_Int32 i = 0; i < seqBridges.getLength(); i++)
+ {
+ Reference<css::lang::XComponent> comp(seqBridges[i], UNO_QUERY);
+ if (comp.is())
+ {
+ try {
+ comp->dispose();
+ }
+ catch ( const css::lang::DisposedException& )
+ {
+ }
+ }
+ }
+}
}
diff --git a/desktop/source/pkgchk/unopkg/unopkg_app.cxx b/desktop/source/pkgchk/unopkg/unopkg_app.cxx
index ef16ea1..938591a 100644
--- a/desktop/source/pkgchk/unopkg/unopkg_app.cxx
+++ b/desktop/source/pkgchk/unopkg/unopkg_app.cxx
@@ -48,7 +48,6 @@
#include "com/sun/star/deployment/ui/PackageManagerDialog.hpp"
#include "com/sun/star/ui/dialogs/XExecutableDialog.hpp"
-#include "com/sun/star/lang/DisposedException.hpp"
#include "boost/scoped_array.hpp"
#include "com/sun/star/ui/dialogs/XDialogClosedListener.hpp"
#include "com/sun/star/bridge/XBridgeFactory.hpp"
@@ -189,42 +188,9 @@ Reference<deployment::XPackage> findPackage(
} // anon namespace
-
-//workaround for some reason the bridge threads which communicate with the uno.exe
-//process are not releases on time
-void disposeBridges(Reference<css::uno::XComponentContext> ctx)
-{
- if (!ctx.is())
- return;
-
- Reference<css::bridge::XBridgeFactory> bridgeFac(
- ctx->getServiceManager()->createInstanceWithContext(
- OUSTR("com.sun.star.bridge.BridgeFactory"), ctx),
- UNO_QUERY);
-
- if (bridgeFac.is())
- {
- const Sequence< Reference<css::bridge::XBridge> >seqBridges = bridgeFac->getExistingBridges();
- for (sal_Int32 i = 0; i < seqBridges.getLength(); i++)
- {
- Reference<css::lang::XComponent> comp(seqBridges[i], UNO_QUERY);
- if (comp.is())
- {
- try {
- comp->dispose();
- }
- catch ( const css::lang::DisposedException& )
- {
- }
- }
- }
- }
-}
-
extern "C" DESKTOP_DLLPUBLIC int unopkg_main()
{
tools::extendApplicationEnvironment();
- DisposeGuard disposeGuard;
bool bNoOtherErrorMsg = false;
OUString subCommand;
bool option_shared = false;
@@ -376,8 +342,7 @@ extern "C" DESKTOP_DLLPUBLIC int unopkg_main()
}
xComponentContext = getUNO(
- disposeGuard, option_verbose, option_shared, subcmd_gui,
- xLocalComponentContext );
+ option_verbose, option_shared, subcmd_gui, xLocalComponentContext );
Reference<deployment::XExtensionManager> xExtensionManager(
deployment::ExtensionManager::get( xComponentContext ) );
@@ -580,6 +545,7 @@ extern "C" DESKTOP_DLLPUBLIC int unopkg_main()
xDialog->startExecuteModal(xListener);
dialogEnded.wait();
+ return 0;
}
else
{
@@ -596,7 +562,7 @@ extern "C" DESKTOP_DLLPUBLIC int unopkg_main()
if (option_verbose)
dp_misc::writeConsole(OUSTR("\n" APP_NAME " done.\n"));
//Force to release all bridges which connect us to the child processes
- disposeBridges(xLocalComponentContext);
+ dp_misc::disposeBridges(xLocalComponentContext);
return 0;
}
catch (const ucb::CommandFailedException &e)
@@ -645,7 +611,7 @@ extern "C" DESKTOP_DLLPUBLIC int unopkg_main()
}
if (!bNoOtherErrorMsg)
dp_misc::writeConsoleError("\n" APP_NAME " failed.\n");
- disposeBridges(xLocalComponentContext);
+ dp_misc::disposeBridges(xLocalComponentContext);
return 1;
}
diff --git a/desktop/source/pkgchk/unopkg/unopkg_misc.cxx b/desktop/source/pkgchk/unopkg/unopkg_misc.cxx
index 52b4ab8..4b1da99 100644
--- a/desktop/source/pkgchk/unopkg/unopkg_misc.cxx
+++ b/desktop/source/pkgchk/unopkg/unopkg_misc.cxx
@@ -364,21 +364,14 @@ void printf_packages(
}
}
-
-
namespace {
//------------------------------------------------------------------------------
-Reference<XComponentContext> bootstrapStandAlone(
- DisposeGuard & disposeGuard, bool /*verbose */)
+Reference<XComponentContext> bootstrapStandAlone()
{
Reference<XComponentContext> xContext =
::cppu::defaultBootstrap_InitialComponentContext();
- // assure disposing of local component context:
- disposeGuard.reset(
- Reference<lang::XComponent>( xContext, UNO_QUERY ) );
-
Reference<lang::XMultiServiceFactory> xServiceManager(
xContext->getServiceManager(), UNO_QUERY_THROW );
// set global process service factory used by unotools config helpers
@@ -392,7 +385,6 @@ Reference<XComponentContext> bootstrapStandAlone(
if (! ::ucbhelper::ContentBroker::initialize( xServiceManager, ucb_args ))
throw RuntimeException( OUSTR("cannot initialize UCB!"), 0 );
- disposeGuard.setDeinitUCB();
return xContext;
}
@@ -468,7 +460,7 @@ OUString getLockFilePath()
}
//==============================================================================
Reference<XComponentContext> getUNO(
- DisposeGuard & disposeGuard, bool verbose, bool shared, bool bGui,
+ bool verbose, bool shared, bool bGui,
Reference<XComponentContext> & out_localContext)
{
// do not create any user data (for the root user) in --shared mode:
@@ -480,8 +472,7 @@ Reference<XComponentContext> getUNO(
// hold lock during process runtime:
static ::desktop::Lockfile s_lockfile( false /* no IPC server */ );
- Reference<XComponentContext> xComponentContext(
- bootstrapStandAlone( disposeGuard, verbose ) );
+ Reference<XComponentContext> xComponentContext( bootstrapStandAlone() );
out_localContext = xComponentContext;
if (::dp_misc::office_is_running()) {
xComponentContext.set(
diff --git a/desktop/source/pkgchk/unopkg/unopkg_shared.h b/desktop/source/pkgchk/unopkg/unopkg_shared.h
index 400e283..a592f46 100644
--- a/desktop/source/pkgchk/unopkg/unopkg_shared.h
+++ b/desktop/source/pkgchk/unopkg/unopkg_shared.h
@@ -28,7 +28,6 @@
#include "dp_misc.h"
#include "com/sun/star/uno/Exception.hpp"
-#include "com/sun/star/lang/XComponent.hpp"
#include "com/sun/star/uno/XComponentContext.hpp"
#include "com/sun/star/ucb/XCommandEnvironment.hpp"
#include "com/sun/star/deployment/XPackage.hpp"
@@ -123,35 +122,6 @@ bool isBootstrapVariable(sal_uInt32 * pIndex);
//##############################################################################
//==============================================================================
-class DisposeGuard
-{
- css::uno::Reference<css::lang::XComponent> m_xComp;
- bool m_bDeinitUCB;
-public:
- DisposeGuard(): m_bDeinitUCB(false) {}
- inline ~DisposeGuard()
- {
- if (m_bDeinitUCB)
- ::ucbhelper::ContentBroker::deinitialize();
-
- if (m_xComp.is())
- m_xComp->dispose();
- }
-
- inline void reset(
- css::uno::Reference<css::lang::XComponent> const & xComp )
- {
- m_xComp = xComp;
- }
-
- inline void setDeinitUCB()
- {
- m_bDeinitUCB = true;
- }
-
-};
-
-//==============================================================================
css::uno::Reference<css::ucb::XCommandEnvironment> createCmdEnv(
css::uno::Reference<css::uno::XComponentContext> const & xContext,
::rtl::OUString const & logFile,
@@ -170,7 +140,7 @@ void printf_packages(
//==============================================================================
css::uno::Reference<css::uno::XComponentContext> getUNO(
- DisposeGuard & disposeGuard, bool verbose, bool shared, bool bGui,
+ bool verbose, bool shared, bool bGui,
css::uno::Reference<css::uno::XComponentContext> & out_LocalComponentContext);
}
More information about the Libreoffice-commits
mailing list