framework/source/accelerators/acceleratorconfiguration.cxx |    6 ++++++
 1 file changed, 6 insertions(+)

New commits:
commit 96491f3f842bb911aca62e74d29865c3f36618e8
Author:     Neil Roberts <bpee...@yahoo.co.uk>
AuthorDate: Mon Sep 15 12:29:48 2025 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Sep 19 09:40:29 2025 +0200

    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 e9e75d722d4. 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.gran...@collabora.co.uk>
    Tested-by: Jenkins

diff --git a/framework/source/accelerators/acceleratorconfiguration.cxx 
b/framework/source/accelerators/acceleratorconfiguration.cxx
index 43a62bfb21e6..34fe76b3849b 100644
--- a/framework/source/accelerators/acceleratorconfiguration.cxx
+++ b/framework/source/accelerators/acceleratorconfiguration.cxx
@@ -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) )

Reply via email to