AcceleratorConfiguration: Don’t reload config for irrelevant module

The XCUBasedAcceleratorConfiguration-s get registered as config change
listeners in ModuleAcceleratorConfiguration::fillCache and
GlobalAcceleratorConfiguration::fillCache. The reloadChanged method then
finds the appropriate config based on the path of the change event.
However, the code didn’t do anything to check whether the config is
actually the one being managed by this accelerator configuration. That
meant for example that if a key was changed in the module configuration
then the global configuration would get notified and it would end up
replacing its configuration for that key with the module one. It would
also end up in the accelerator configuration for modules for any other
documents that happen to be open.

One way to manifest this bug is as follows:

• Create a new text document
• Tools → Customize
• Select the keyboard tab
• Select F7 in the list of keys
• Type “word count” in the search box
• Press “assign”
• Press OK
• Tools → Customize again
• Select F7 in the list of keys
• Press “delete”
• Press OK

Now look at the tools menu. Notice that F7 is still assigned to the word
count option. This is because the key has been copied into the global
configuration. The delete only deleted it from the module configuration.

Note that the messed up configuration is only stored in the read cache
so it doesn’t end up getting saved. If you restart LibreOffice then the
expected behaviour is restored.

This problem might have been added in e9e75d722d. It looks like before
that it might have been adding separate listeners for global and module
configs. Ie, connectToResourse has either PresetHandler::E_MODULES or
PresetHandle::E_GLOBAL.

Change-Id: Iac8f50f3668eaadc9a62f562d5923b93cc3d0721
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190971
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
This commit is contained in:
Neil Roberts
2025-09-19 09:40:29 +02:00
committed by Noel Grandin
parent c393229168
commit 96491f3f84
@@ -1194,6 +1194,9 @@ void XCUBasedAcceleratorConfiguration::removeKeyFromConfiguration( const css::aw
void XCUBasedAcceleratorConfiguration::reloadChanged( const OUString& sPrimarySecondary, std::u16string_view sGlobalModules, const OUString& sModule, const OUString& sKey )
{
if ( sGlobalModules != m_sGlobalOrModules )
return;
css::uno::Reference< css::container::XNameAccess > xAccess;
css::uno::Reference< css::container::XNameContainer > xContainer;
@@ -1202,6 +1205,9 @@ void XCUBasedAcceleratorConfiguration::reloadChanged( const OUString& sPrimarySe
xAccess->getByName(CFG_ENTRY_GLOBAL) >>= xContainer;
else
{
if ( sModule != m_sModuleCFG )
return;
css::uno::Reference< css::container::XNameAccess > xModules;
xAccess->getByName(CFG_ENTRY_MODULES) >>= xModules;
if ( !xModules->hasByName(sModule) )