framework/inc/xml/acceleratorconfigurationreader.hxx | 10 ------- framework/inc/xml/acceleratorconfigurationwriter.hxx | 11 ------- framework/source/accelerators/acceleratorconfiguration.cxx | 14 +++++----- framework/source/accelerators/keymapping.cxx | 11 ++++++- framework/source/inc/accelerators/acceleratorconfiguration.hxx | 4 -- framework/source/inc/accelerators/keymapping.hxx | 3 +- framework/source/xml/acceleratorconfigurationreader.cxx | 5 ++- framework/source/xml/acceleratorconfigurationwriter.cxx | 5 ++- 8 files changed, 26 insertions(+), 37 deletions(-)
New commits: commit 7d9ac365039a23b704738b63a54bbbae6e9f6f3a Author: Stephan Bergmann <sberg...@redhat.com> Date: Tue Jan 26 15:09:30 2016 +0100 Replace salhelper::SingletonRef with rtl::Static When destroying the static vcl::CommandInfoProvider aProvider from vcl::CommandInfoProvider::Instance (vcl/source/helper/commandinfoprovider.cxx) during exit, it releases its mxCachedGlobalAcceleratorConfiguration reference on GlobalAcceleratorConfiguration (framework/source/accelerators/globalacceleratorconfiguration.cxx), which may get destroyed, whose base class framework::XCUBasedAcceleratorConfiguration (framework/source/inc/accelerators/acceleratorconfiguration.hxx) has a salhelper::SingletonRef<framework::KeyMapping> member, whose destructor (include/salhelper/singletonref.hxx) uses salhelper::SingletonRef<framework::KeyMapping>::SingletonLockInit::operator ()'s static osl::Mutex aInstance. If, during construction, the instantiation of salhelper::SingletonRef<framework::KeyMapping>::SingletonLockInit::operator ()'s static osl::Mutex aInstance finishes before the instantiation of vcl::CommandInfoProvider::Instance's static vcl::CommandInfoProvider aProvider, the corresponding atexit cleanup actions will be recorded in the right order, causing the above chain of calls to find the static Mutex still alive when used from within the static CommandInfoProvider's destruction. However, vcl::CommandInfoProvider's mxCachedGlobalAcceleratorConfiguration is only set to css::ui::GlobalAcceleratorConfiguration::create in vcl::CommandInfoProvider::GetGlobalAcceleratorConfiguration, so the instantiation of the static Mutex instance can finish after the instantiation of the static CommandInfoProvider instance, recording the atexit cleanup actions in the wrong order, causing the static Mutex to be used after destruction. This occasionally caused PythonTest_sfx2_python to hang during exit for me on Linux, where trying to lock a destroyed pthread mutex can apparently deadlock. rtl::Static does away with the need to do anything in the destructor, at the expense of always keeping the instance alive until exit (and not being able to recreate an already destroyed instance during exit, but code that would require that behavior would probably already be broken to begin with), so the order of creation of the CommandInfoProvider and GlobalAcceleratorConfiguration instances becomes less of a concern. Change-Id: Id6e3860ad9e5b7045980a0b9bf9eaef2e24129bb diff --git a/framework/inc/xml/acceleratorconfigurationreader.hxx b/framework/inc/xml/acceleratorconfigurationreader.hxx index 6dc343d..90365e5 100644 --- a/framework/inc/xml/acceleratorconfigurationreader.hxx +++ b/framework/inc/xml/acceleratorconfigurationreader.hxx @@ -23,7 +23,6 @@ #include <xml/saxnamespacefilter.hxx> // HACK: needed for MSVC 2013 ENABLE_LTO build: WeakImplHelper<XDocumentHandler> #include <accelerators/acceleratorcache.hxx> -#include <accelerators/keymapping.hxx> #include <macros/xinterface.hxx> #include <general.h> @@ -31,7 +30,6 @@ #include <com/sun/star/xml/sax/XLocator.hpp> -#include <salhelper/singletonref.hxx> #include <cppuhelper/implbase.hxx> #include <rtl/ustring.hxx> @@ -85,14 +83,6 @@ class AcceleratorConfigurationReader : public ::cppu::WeakImplHelper< css::xml:: occurs recursive inside xml. */ bool m_bInsideAcceleratorItem; - /** @short is used to map key codes to its - string representation. - - @descr To perform this operation is - created only one time and kept - alive forever ...*/ - ::salhelper::SingletonRef< KeyMapping > m_rKeyMapping; - /** @short provide information about the parsing state. @descr We use it to find out the line and column, where diff --git a/framework/inc/xml/acceleratorconfigurationwriter.hxx b/framework/inc/xml/acceleratorconfigurationwriter.hxx index d46b2e9..e71c889 100644 --- a/framework/inc/xml/acceleratorconfigurationwriter.hxx +++ b/framework/inc/xml/acceleratorconfigurationwriter.hxx @@ -21,12 +21,9 @@ #define INCLUDED_FRAMEWORK_INC_XML_ACCELERATORCONFIGURATIONWRITER_HXX #include <accelerators/acceleratorcache.hxx> -#include <accelerators/keymapping.hxx> #include <general.h> #include <com/sun/star/xml/sax/XDocumentHandler.hpp> - -#include <salhelper/singletonref.hxx> #include <rtl/ustring.hxx> namespace framework{ @@ -45,14 +42,6 @@ class AcceleratorConfigurationWriter writer must work on. */ const AcceleratorCache& m_rContainer; - /** @short is used to map key codes to its - string representation. - - @descr To perform this operation is - created only one times and holded - alive forever ...*/ - ::salhelper::SingletonRef< KeyMapping > m_rKeyMapping; - // interface public: diff --git a/framework/source/accelerators/acceleratorconfiguration.cxx b/framework/source/accelerators/acceleratorconfiguration.cxx index 3fb8331..586011a 100644 --- a/framework/source/accelerators/acceleratorconfiguration.cxx +++ b/framework/source/accelerators/acceleratorconfiguration.cxx @@ -18,7 +18,7 @@ */ #include <accelerators/acceleratorconfiguration.hxx> - +#include <accelerators/keymapping.hxx> #include <accelerators/presethandler.hxx> #include <xml/saxnamespacefilter.hxx> @@ -57,10 +57,10 @@ namespace framework const char CFG_ENTRY_SECONDARY[] = "SecondaryKeys"; const char CFG_PROP_COMMAND[] = "Command"; - OUString lcl_getKeyString(salhelper::SingletonRef<framework::KeyMapping>& _rKeyMapping, const css::awt::KeyEvent& aKeyEvent) + OUString lcl_getKeyString(const css::awt::KeyEvent& aKeyEvent) { const sal_Int32 nBeginIndex = 4; // "KEY_" is the prefix of a identifier... - OUStringBuffer sKeyBuffer((_rKeyMapping->mapCodeToIdentifier(aKeyEvent.KeyCode)).copy(nBeginIndex)); + OUStringBuffer sKeyBuffer((KeyMapping::get().mapCodeToIdentifier(aKeyEvent.KeyCode)).copy(nBeginIndex)); if ( (aKeyEvent.Modifiers & css::awt::KeyModifier::SHIFT) == css::awt::KeyModifier::SHIFT ) sKeyBuffer.append("_SHIFT"); @@ -1135,7 +1135,7 @@ void XCUBasedAcceleratorConfiguration::impl_ts_load( bool bPreferred, const css: sal_Int32 nIndex = 0; OUString sKeyCommand = sKey.getToken(0, '_', nIndex); OUString sPrefix("KEY_"); - aKeyEvent.KeyCode = m_rKeyMapping->mapIdentifierToCode(sPrefix + sKeyCommand); + aKeyEvent.KeyCode = KeyMapping::get().mapIdentifierToCode(sPrefix + sKeyCommand); css::uno::Sequence< OUString > sToken(4); const sal_Int32 nToken = 4; @@ -1289,7 +1289,7 @@ void XCUBasedAcceleratorConfiguration::insertKeyToConfiguration( const css::awt: xModules->getByName(m_sModuleCFG) >>= xContainer; } - const OUString sKey = lcl_getKeyString(m_rKeyMapping,aKeyEvent); + const OUString sKey = lcl_getKeyString(aKeyEvent); css::uno::Reference< css::container::XNameAccess > xKey; css::uno::Reference< css::container::XNameContainer > xCommand; if ( !xContainer->hasByName(sKey) ) @@ -1329,7 +1329,7 @@ void XCUBasedAcceleratorConfiguration::removeKeyFromConfiguration( const css::aw xModules->getByName(m_sModuleCFG) >>= xContainer; } - const OUString sKey = lcl_getKeyString(m_rKeyMapping,aKeyEvent); + const OUString sKey = lcl_getKeyString(aKeyEvent); xContainer->removeByName(sKey); } @@ -1355,7 +1355,7 @@ void XCUBasedAcceleratorConfiguration::reloadChanged( const OUString& sPrimarySe sal_Int32 nIndex = 0; sKeyIdentifier = sKey.getToken(0, '_', nIndex); - aKeyEvent.KeyCode = m_rKeyMapping->mapIdentifierToCode("KEY_"+sKeyIdentifier); + aKeyEvent.KeyCode = KeyMapping::get().mapIdentifierToCode("KEY_"+sKeyIdentifier); css::uno::Sequence< OUString > sToken(3); const sal_Int32 nToken = 3; diff --git a/framework/source/accelerators/keymapping.cxx b/framework/source/accelerators/keymapping.cxx index ec02c32..02a0278 100644 --- a/framework/source/accelerators/keymapping.cxx +++ b/framework/source/accelerators/keymapping.cxx @@ -20,6 +20,7 @@ #include <accelerators/keymapping.hxx> #include <com/sun/star/awt/Key.hpp> +#include <rtl/instance.hxx> namespace framework { @@ -152,8 +153,14 @@ KeyMapping::KeyMapping() } } -KeyMapping::~KeyMapping() -{ +namespace { + +struct Instance: public rtl::Static<KeyMapping, Instance> {}; + +} + +KeyMapping & KeyMapping::get() { + return Instance::get(); } sal_uInt16 KeyMapping::mapIdentifierToCode(const OUString& sIdentifier) diff --git a/framework/source/inc/accelerators/acceleratorconfiguration.hxx b/framework/source/inc/accelerators/acceleratorconfiguration.hxx index be26772..e0d8755 100644 --- a/framework/source/inc/accelerators/acceleratorconfiguration.hxx +++ b/framework/source/inc/accelerators/acceleratorconfiguration.hxx @@ -22,7 +22,6 @@ #include <accelerators/presethandler.hxx> #include <accelerators/acceleratorcache.hxx> -#include <accelerators/keymapping.hxx> #include <macros/xinterface.hxx> #include <macros/xtypeprovider.hxx> #include <general.h> @@ -46,7 +45,6 @@ #include <cppuhelper/propshlp.hxx> #include <cppuhelper/implbase.hxx> -#include <salhelper/singletonref.hxx> // definition @@ -257,8 +255,6 @@ class XCUBasedAcceleratorConfiguration : public ::cppu::WeakImplHelper< OUString m_sGlobalOrModules; OUString m_sModuleCFG; - ::salhelper::SingletonRef< KeyMapping > m_rKeyMapping; - // native interface! public: diff --git a/framework/source/inc/accelerators/keymapping.hxx b/framework/source/inc/accelerators/keymapping.hxx index dfdd327..3b6b7a2 100644 --- a/framework/source/inc/accelerators/keymapping.hxx +++ b/framework/source/inc/accelerators/keymapping.hxx @@ -77,7 +77,8 @@ class KeyMapping public: KeyMapping(); - virtual ~KeyMapping(); + + static KeyMapping & get(); /** @short return a suitable key code for the specified key identifier. diff --git a/framework/source/xml/acceleratorconfigurationreader.cxx b/framework/source/xml/acceleratorconfigurationreader.cxx index 000e831..bb282d0 100644 --- a/framework/source/xml/acceleratorconfigurationreader.cxx +++ b/framework/source/xml/acceleratorconfigurationreader.cxx @@ -17,6 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <accelerators/keymapping.hxx> #include <xml/acceleratorconfigurationreader.hxx> #include <acceleratorconst.h> @@ -121,7 +124,7 @@ void SAL_CALL AcceleratorConfigurationReader::startElement(const OUString& break; case E_ATTRIBUTE_KEYCODE : - aEvent.KeyCode = m_rKeyMapping->mapIdentifierToCode(sValue); + aEvent.KeyCode = KeyMapping::get().mapIdentifierToCode(sValue); break; case E_ATTRIBUTE_MOD_SHIFT : diff --git a/framework/source/xml/acceleratorconfigurationwriter.cxx b/framework/source/xml/acceleratorconfigurationwriter.cxx index 07c0a12..181acec 100644 --- a/framework/source/xml/acceleratorconfigurationwriter.cxx +++ b/framework/source/xml/acceleratorconfigurationwriter.cxx @@ -17,6 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <accelerators/keymapping.hxx> #include <xml/acceleratorconfigurationwriter.hxx> #include <acceleratorconst.h> @@ -94,7 +97,7 @@ void AcceleratorConfigurationWriter::impl_ts_writeKeyCommandPair(const css::awt: ::comphelper::AttributeList* pAttribs = new ::comphelper::AttributeList; css::uno::Reference< css::xml::sax::XAttributeList > xAttribs (static_cast< css::xml::sax::XAttributeList* >(pAttribs) , css::uno::UNO_QUERY_THROW); - OUString sKey = m_rKeyMapping->mapCodeToIdentifier(aKey.KeyCode); + OUString sKey = KeyMapping::get().mapCodeToIdentifier(aKey.KeyCode); // TODO check if key is empty! pAttribs->AddAttribute(AL_ATTRIBUTE_KEYCODE, ATTRIBUTE_TYPE_CDATA, sKey ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits