[Libreoffice-commits] core.git: 2 commits - embeddedobj/source framework/source framework/util
Noel (via logerrit)
logerrit at kemper.freedesktop.org
Sat Mar 20 08:31:30 UTC 2021
embeddedobj/source/commonembedding/miscobj.cxx | 30 ++++++++------------
embeddedobj/source/inc/commonembobj.hxx | 3 +-
framework/source/uielement/uicommanddescription.cxx | 23 ---------------
framework/util/fwk.component | 3 +-
4 files changed, 18 insertions(+), 41 deletions(-)
New commits:
commit b7d10f138182b0f2d9b682582f73de8d6ceceb8d
Author: Noel <noel.grandin at collabora.co.uk>
AuthorDate: Thu Mar 18 11:26:03 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Mar 20 09:30:57 2021 +0100
use single-use attribute for UICommandDescription
instead of rtl::Instance, which means it will get
cleaned up when UNO shuts down
Change-Id: Ia26871e1a2cf2cc6150d681f3a40b42269fb65c0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112686
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/framework/source/uielement/uicommanddescription.cxx b/framework/source/uielement/uicommanddescription.cxx
index d791ddfd89ab..4d9fccf5af41 100644
--- a/framework/source/uielement/uicommanddescription.cxx
+++ b/framework/source/uielement/uicommanddescription.cxx
@@ -710,33 +710,12 @@ sal_Bool SAL_CALL UICommandDescription::hasElements()
} // namespace framework
-namespace {
-
-struct Instance {
- explicit Instance(
- css::uno::Reference<css::uno::XComponentContext> const & context):
- instance(static_cast<cppu::OWeakObject *>(
- new framework::UICommandDescription(context)))
- {
- }
-
- css::uno::Reference<css::uno::XInterface> instance;
-};
-
-struct Singleton:
- public rtl::StaticWithArg<
- Instance, css::uno::Reference<css::uno::XComponentContext>, Singleton>
-{};
-
-}
-
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
com_sun_star_comp_framework_UICommandDescription_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
- return cppu::acquire(static_cast<cppu::OWeakObject *>(
- Singleton::get(context).instance.get()));
+ return cppu::acquire(new framework::UICommandDescription(context));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/util/fwk.component b/framework/util/fwk.component
index 12ce9ec7d966..5c9085759b19 100644
--- a/framework/util/fwk.component
+++ b/framework/util/fwk.component
@@ -161,7 +161,8 @@
<singleton name="com.sun.star.ui.theUICategoryDescription"/>
</implementation>
<implementation name="com.sun.star.comp.framework.UICommandDescription"
- constructor="com_sun_star_comp_framework_UICommandDescription_get_implementation">
+ constructor="com_sun_star_comp_framework_UICommandDescription_get_implementation"
+ single-instance="true">
<service name="com.sun.star.frame.UICommandDescription"/>
<singleton name="com.sun.star.frame.theUICommandDescription"/>
</implementation>
commit 3e12b2fb64350938a3efe3252e84f62aa608356e
Author: Noel Grandin <noel at peralex.com>
AuthorDate: Fri Mar 19 14:44:16 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Mar 20 09:30:32 2021 +0100
use unique_ptr in OCommonEmbeddedObject
Change-Id: I2258838cbbe242dbe31500ecd6f29c315a335b71
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112743
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/embeddedobj/source/commonembedding/miscobj.cxx b/embeddedobj/source/commonembedding/miscobj.cxx
index c62527f84398..c30a4bc64168 100644
--- a/embeddedobj/source/commonembedding/miscobj.cxx
+++ b/embeddedobj/source/commonembedding/miscobj.cxx
@@ -41,8 +41,7 @@ using namespace ::com::sun::star;
OCommonEmbeddedObject::OCommonEmbeddedObject( const uno::Reference< uno::XComponentContext >& rxContext,
const uno::Sequence< beans::NamedValue >& aObjProps )
-: m_pInterfaceContainer( nullptr )
-, m_bReadOnly( false )
+: m_bReadOnly( false )
, m_bDisposed( false )
, m_bClosed( false )
, m_nObjectState( -1 )
@@ -67,8 +66,7 @@ OCommonEmbeddedObject::OCommonEmbeddedObject(
const uno::Sequence< beans::NamedValue >& aObjProps,
const uno::Sequence< beans::PropertyValue >& aMediaDescr,
const uno::Sequence< beans::PropertyValue >& aObjectDescr )
-: m_pInterfaceContainer( nullptr )
-, m_bReadOnly( false )
+: m_bReadOnly( false )
, m_bDisposed( false )
, m_bClosed( false )
, m_nObjectState( embed::EmbedStates::LOADED )
@@ -242,17 +240,14 @@ OCommonEmbeddedObject::~OCommonEmbeddedObject()
return;
osl_atomic_increment(&m_refCount);
- try {
- lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) );
-
- if ( m_pInterfaceContainer )
- {
+ if ( m_pInterfaceContainer )
+ {
+ try {
+ lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) );
m_pInterfaceContainer->disposeAndClear( aSource );
-
- delete m_pInterfaceContainer;
- m_pInterfaceContainer = nullptr;
- }
- } catch( const uno::Exception& ) {}
+ } catch( const uno::Exception& ) {}
+ m_pInterfaceContainer.reset();
+ }
try {
if ( m_xDocHolder.is() )
@@ -429,7 +424,7 @@ void SAL_CALL OCommonEmbeddedObject::addStateChangeListener( const uno::Referenc
throw lang::DisposedException(); // TODO
if ( !m_pInterfaceContainer )
- m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex );
+ m_pInterfaceContainer.reset(new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex ));
m_pInterfaceContainer->addInterface( cppu::UnoType<embed::XStateChangeListener>::get(),
xListener );
@@ -494,6 +489,7 @@ void SAL_CALL OCommonEmbeddedObject::close( sal_Bool bDeliverOwnership )
}
m_pInterfaceContainer->disposeAndClear( aSource );
+ m_pInterfaceContainer.reset();
}
m_bDisposed = true; // the object is disposed now for outside
@@ -548,7 +544,7 @@ void SAL_CALL OCommonEmbeddedObject::addCloseListener( const uno::Reference< uti
throw lang::DisposedException(); // TODO
if ( !m_pInterfaceContainer )
- m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper(m_aMutex);
+ m_pInterfaceContainer.reset(new ::cppu::OMultiTypeInterfaceContainerHelper(m_aMutex));
m_pInterfaceContainer->addInterface( cppu::UnoType<util::XCloseListener>::get(), xListener );
}
@@ -570,7 +566,7 @@ void SAL_CALL OCommonEmbeddedObject::addEventListener( const uno::Reference< doc
throw lang::DisposedException(); // TODO
if ( !m_pInterfaceContainer )
- m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper(m_aMutex);
+ m_pInterfaceContainer.reset(new ::cppu::OMultiTypeInterfaceContainerHelper(m_aMutex));
m_pInterfaceContainer->addInterface( cppu::UnoType<document::XEventListener>::get(), xListener );
}
diff --git a/embeddedobj/source/inc/commonembobj.hxx b/embeddedobj/source/inc/commonembobj.hxx
index 2294b0d7e915..e28b3654d1e7 100644
--- a/embeddedobj/source/inc/commonembobj.hxx
+++ b/embeddedobj/source/inc/commonembobj.hxx
@@ -35,6 +35,7 @@
#include <cppuhelper/weak.hxx>
#include <rtl/ref.hxx>
#include <map>
+#include <memory>
namespace com::sun::star {
namespace embed {
@@ -84,7 +85,7 @@ protected:
rtl::Reference<DocumentHolder> m_xDocHolder;
- ::cppu::OMultiTypeInterfaceContainerHelper* m_pInterfaceContainer;
+ std::unique_ptr<::cppu::OMultiTypeInterfaceContainerHelper> m_pInterfaceContainer;
bool m_bReadOnly;
More information about the Libreoffice-commits
mailing list