[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - include/vcl vcl/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Fri Sep 11 12:21:48 UTC 2020


 include/vcl/treelist.hxx      |    1 
 vcl/source/app/salvtables.cxx |   54 ++++++++++++++++++++++++++++++++++++------
 2 files changed, 48 insertions(+), 7 deletions(-)

New commits:
commit b19e522654562b8f01d0b3af4078c43ce46834e4
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Sep 10 09:33:39 2020 +0100
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Fri Sep 11 14:21:16 2020 +0200

    tdf#131581 inhibit updates during all_foreach
    
    Change-Id: I8494b4c9175e427bfb89696d49c2da7607af37ef
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102380
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>

diff --git a/include/vcl/treelist.hxx b/include/vcl/treelist.hxx
index 85aba58f8818..46d3374d8caf 100644
--- a/include/vcl/treelist.hxx
+++ b/include/vcl/treelist.hxx
@@ -132,6 +132,7 @@ public:
                         );
 
     void                EnableInvalidate( bool bEnable );
+    bool                IsEnableInvalidate() const { return mbEnableInvalidate; }
 
     // Notify all Listeners
     void                InvalidateEntry( SvTreeListEntry* );
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index ccfe3ac7d542..dbdff77e891f 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -3182,6 +3182,37 @@ class SalInstanceTreeView;
 
 static SalInstanceTreeView* g_DragSource;
 
+namespace
+{
+    class UpdateGuard
+    {
+    private:
+        SvTabListBox& m_rTreeView;
+        bool m_bOrigUpdate;
+        bool m_bOrigEnableInvalidate;
+
+    public:
+        UpdateGuard(SvTabListBox& rTreeView)
+            : m_rTreeView(rTreeView)
+            , m_bOrigUpdate(m_rTreeView.IsUpdateMode())
+            , m_bOrigEnableInvalidate(m_rTreeView.GetModel()->IsEnableInvalidate())
+        {
+            if (m_bOrigUpdate)
+                m_rTreeView.SetUpdateMode(false);
+            if (m_bOrigEnableInvalidate)
+                m_rTreeView.GetModel()->EnableInvalidate(false);
+        }
+
+        ~UpdateGuard()
+        {
+            if (m_bOrigUpdate)
+                m_rTreeView.SetUpdateMode(true);
+            if (m_bOrigEnableInvalidate)
+                m_rTreeView.GetModel()->EnableInvalidate(true);
+        }
+    };
+}
+
 class SalInstanceTreeView : public SalInstanceContainer, public virtual weld::TreeView
 {
 private:
@@ -3251,6 +3282,13 @@ private:
         pEntry->AddItem(std::move(xCell));
     }
 
+    void InvalidateModelEntry(SvTreeListEntry* pEntry)
+    {
+        if (!m_xTreeView->GetModel()->IsEnableInvalidate())
+            return;
+        m_xTreeView->ModelHasEntryInvalidated(pEntry);
+    }
+
 public:
     SalInstanceTreeView(SvTabListBox* pTreeView, SalInstanceBuilder* pBuilder, bool bTakeOwnership)
         : SalInstanceContainer(pTreeView, pBuilder, bTakeOwnership)
@@ -3714,7 +3752,7 @@ public:
             assert(dynamic_cast<SvLBoxString*>(&rItem));
             static_cast<SvLBoxString&>(rItem).SetText(rText);
         }
-        m_xTreeView->ModelHasEntryInvalidated(pEntry);
+        InvalidateModelEntry(pEntry);
     }
 
     virtual void set_text(int pos, const OUString& rText, int col) override
@@ -3738,7 +3776,7 @@ public:
                 if (rItem.GetType() == SvLBoxItemType::String)
                 {
                     rItem.Enable(bSensitive);
-                    m_xTreeView->ModelHasEntryInvalidated(pEntry);
+                    InvalidateModelEntry(pEntry);
                     break;
                 }
             }
@@ -3751,7 +3789,7 @@ public:
         SvLBoxItem& rItem = pEntry->GetItem(col);
         rItem.Enable(bSensitive);
 
-        m_xTreeView->ModelHasEntryInvalidated(pEntry);
+        InvalidateModelEntry(pEntry);
     }
 
     using SalInstanceWidget::set_sensitive;
@@ -3833,7 +3871,7 @@ public:
                 break;
         }
 
-        m_xTreeView->ModelHasEntryInvalidated(pEntry);
+        InvalidateModelEntry(pEntry);
     }
 
     virtual void set_toggle(int pos, TriState eState, int col) override
@@ -3864,7 +3902,7 @@ public:
         assert(dynamic_cast<SvLBoxString*>(&rItem));
         static_cast<SvLBoxString&>(rItem).Emphasize(bOn);
 
-        m_xTreeView->ModelHasEntryInvalidated(pEntry);
+        InvalidateModelEntry(pEntry);
     }
 
     virtual void set_text_emphasis(const weld::TreeIter& rIter, bool bOn, int col) override
@@ -3900,7 +3938,7 @@ public:
         assert(dynamic_cast<SvLBoxString*>(&rItem));
         static_cast<SvLBoxString&>(rItem).Align(fAlign);
 
-        m_xTreeView->ModelHasEntryInvalidated(pEntry);
+        InvalidateModelEntry(pEntry);
     }
 
     virtual void set_text_align(const weld::TreeIter& rIter, double fAlign, int col) override
@@ -3962,7 +4000,7 @@ public:
         }
 
         m_xTreeView->SetEntryHeight(pEntry);
-        m_xTreeView->ModelHasEntryInvalidated(pEntry);
+        InvalidateModelEntry(pEntry);
     }
 
     virtual void set_image(int pos, const OUString& rImage, int col) override
@@ -4303,6 +4341,8 @@ public:
 
     virtual void all_foreach(const std::function<bool(weld::TreeIter&)>& func) override
     {
+        UpdateGuard aGuard(*m_xTreeView);
+
         SalInstanceTreeIter aVclIter(m_xTreeView->First());
         while (aVclIter.iter)
         {


More information about the Libreoffice-commits mailing list