[Libreoffice-commits] core.git: sc/source sfx2/source svx/source sw/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Mon Aug 26 19:45:13 UTC 2019


 sc/source/ui/Accessibility/DrawModelBroadcaster.cxx |    1 
 sfx2/source/doc/sfxbasemodel.cxx                    |   21 ++++++++++++--------
 svx/source/accessibility/AccessibleShape.cxx        |    4 +--
 sw/source/core/access/accmap.cxx                    |    1 
 4 files changed, 17 insertions(+), 10 deletions(-)

New commits:
commit f0f576d2d91e8baa674fae65b3e2a024f1f81c45
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Aug 26 12:37:07 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Aug 26 21:43:33 2019 +0200

    fix impress crash in shape listener
    
    after
        commit ec940941e0bd7db15c5cf7d43df82226e0d849dc
        Date:   Tue Aug 20 17:03:13 2019 +0200
        tdf#119388 add new UNO listener/broadcaster
    
    grumble grumble stoopid AccessiblePageShape that overrides
    AccessibleShape but doesn't actually set any shape on it.
    
    Also, there appear to multiple copies of something listening to the same
    shape somewhere, but I didn't track that further.
    
    Change-Id: I78713716788dd99b1f56519d960b43e5538c1304
    Reviewed-on: https://gerrit.libreoffice.org/78120
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/source/ui/Accessibility/DrawModelBroadcaster.cxx b/sc/source/ui/Accessibility/DrawModelBroadcaster.cxx
index 5b63c9926baf..c4b40df72df9 100644
--- a/sc/source/ui/Accessibility/DrawModelBroadcaster.cxx
+++ b/sc/source/ui/Accessibility/DrawModelBroadcaster.cxx
@@ -54,6 +54,7 @@ void SAL_CALL ScDrawModelBroadcaster::addShapeEventListener(
                 const css::uno::Reference< css::drawing::XShape >& xShape,
                 const uno::Reference< document::XShapeEventListener >& xListener )
 {
+    assert(xShape.is() && "no shape?");
     osl::MutexGuard aGuard(maListenerMutex);
     auto rv = maShapeListeners.emplace(xShape, xListener);
     assert(rv.second && "duplicate listener?");
diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index 19cfb2dd49f3..08c5f83ba54d 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -199,7 +199,7 @@ struct IMPL_SfxBaseModel_DataContainer : public ::sfx2::IModifiableDocument
     OUString                                                   m_aPreusedFilterName     ;
     ::cppu::OMultiTypeInterfaceContainerHelper                 m_aInterfaceContainer    ;
     std::unordered_map<css::uno::Reference< css::drawing::XShape >,
-                       css::uno::Reference< css::document::XShapeEventListener >> maShapeListeners;
+                       std::vector<css::uno::Reference< css::document::XShapeEventListener >>> maShapeListeners;
     Reference< XInterface >                                    m_xParent                ;
     Reference< frame::XController >                            m_xCurrent               ;
     Reference< document::XDocumentProperties >                 m_xDocumentProperties    ;
@@ -2376,11 +2376,10 @@ void SAL_CALL SfxBaseModel::removeEventListener( const Reference< document::XEve
 
 void SAL_CALL SfxBaseModel::addShapeEventListener( const css::uno::Reference< css::drawing::XShape >& xShape, const Reference< document::XShapeEventListener >& xListener )
 {
+    assert(xShape.is() && "no shape?");
     SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING );
 
-    auto rv = m_pData->maShapeListeners.emplace(xShape, xListener);
-    assert(rv.second && "duplicate listener?");
-    (void)rv;
+    m_pData->maShapeListeners[xShape].push_back(xListener);
 }
 
 
@@ -2394,9 +2393,14 @@ void SAL_CALL SfxBaseModel::removeShapeEventListener( const css::uno::Reference<
     auto it = m_pData->maShapeListeners.find(xShape);
     if (it != m_pData->maShapeListeners.end())
     {
-        assert(it->second == xListener && "removing wrong listener?");
-        (void)xListener;
-        m_pData->maShapeListeners.erase(it);
+        auto rVec = it->second;
+        auto it2 = std::find(rVec.begin(), rVec.end(), xListener);
+        if (it2 != rVec.end())
+        {
+            rVec.erase(it2);
+            if (rVec.empty())
+            m_pData->maShapeListeners.erase(it);
+        }
     }
 }
 
@@ -3256,7 +3260,8 @@ void SfxBaseModel::notifyEvent( const document::EventObject& aEvent ) const
         {
             auto it = m_pData->maShapeListeners.find(xShape);
             if (it != m_pData->maShapeListeners.end())
-                it->second->notifyShapeEvent(aEvent);
+                for (auto const & rListenerUnoRef : it->second)
+                    rListenerUnoRef->notifyShapeEvent(aEvent);
         }
     }
 }
diff --git a/svx/source/accessibility/AccessibleShape.cxx b/svx/source/accessibility/AccessibleShape.cxx
index e9966e3c63ef..5bf62fccfd3b 100644
--- a/svx/source/accessibility/AccessibleShape.cxx
+++ b/svx/source/accessibility/AccessibleShape.cxx
@@ -140,7 +140,7 @@ void AccessibleShape::Init()
         mpChildrenManager->Update();
 
     // Register at model as document::XEventListener.
-    if (maShapeTreeInfo.GetModelBroadcaster().is())
+    if (mxShape.is() && maShapeTreeInfo.GetModelBroadcaster().is())
         maShapeTreeInfo.GetModelBroadcaster()->addShapeEventListener(mxShape,
             static_cast<document::XShapeEventListener*>(this));
 
@@ -1064,7 +1064,7 @@ void AccessibleShape::disposing()
         pStateSet->RemoveState (AccessibleStateType::FOCUSED);
 
     // Unregister from model.
-    if (maShapeTreeInfo.GetModelBroadcaster().is())
+    if (mxShape.is() && maShapeTreeInfo.GetModelBroadcaster().is())
         maShapeTreeInfo.GetModelBroadcaster()->removeShapeEventListener(mxShape,
             static_cast<document::XShapeEventListener*>(this));
 
diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx
index 1516853e1fb1..3a35b5c03e26 100644
--- a/sw/source/core/access/accmap.cxx
+++ b/sw/source/core/access/accmap.cxx
@@ -172,6 +172,7 @@ void SAL_CALL SwDrawModellListener_Impl::addShapeEventListener(
                 const css::uno::Reference< css::drawing::XShape >& xShape,
                 const uno::Reference< document::XShapeEventListener >& xListener )
 {
+    assert(xShape.is() && "no shape?");
     osl::MutexGuard aGuard(maListenerMutex);
     auto rv = maShapeListeners.emplace(xShape, xListener);
     assert(rv.second && "duplicate listener?");


More information about the Libreoffice-commits mailing list