diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-09-10 09:33:39 +0100 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2020-11-30 18:25:18 +0100 |
commit | c5e4f29fde9ed9e10dbaf1b22f9ad8ada528300b (patch) | |
tree | 2eea374733747d1bda2d7a4ffab2e50142da7272 | |
parent | 43c2357aae03a73801ab8b7e47761d3c43f9f0d5 (diff) |
tdf#131581 inhibit updates during all_foreach
Change-Id: I8494b4c9175e427bfb89696d49c2da7607af37ef
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102371
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106887
Tested-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
-rw-r--r-- | include/vcl/salvtables.hxx | 2 | ||||
-rw-r--r-- | include/vcl/treelist.hxx | 1 | ||||
-rw-r--r-- | vcl/source/app/salvtables.cxx | 55 |
3 files changed, 50 insertions, 8 deletions
diff --git a/include/vcl/salvtables.hxx b/include/vcl/salvtables.hxx index 9673ef62c5b5..7e98f133251b 100644 --- a/include/vcl/salvtables.hxx +++ b/include/vcl/salvtables.hxx @@ -1151,6 +1151,8 @@ private: void update_checkbutton_column_width(SvTreeListEntry* pEntry); + void InvalidateModelEntry(SvTreeListEntry* pEntry); + void do_set_toggle(SvTreeListEntry* pEntry, TriState eState, int col); static TriState do_get_toggle(SvTreeListEntry* pEntry, int col); diff --git a/include/vcl/treelist.hxx b/include/vcl/treelist.hxx index 20045cb21804..ffb359a4e8f8 100644 --- a/include/vcl/treelist.hxx +++ b/include/vcl/treelist.hxx @@ -133,6 +133,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 b0e33be5cf6f..dd07cd7a5979 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -3237,6 +3237,37 @@ int SalInstanceTreeView::to_external_model(int col) const return col; } +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); + } + }; +} + bool SalInstanceTreeView::IsDummyEntry(SvTreeListEntry* pEntry) const { return m_xTreeView->GetEntryText(pEntry).trim() == "<dummy>"; @@ -3337,6 +3368,13 @@ void SalInstanceTreeView::update_checkbutton_column_width(SvTreeListEntry* pEntr m_xTreeView->CheckBoxInserted(pEntry); } +void SalInstanceTreeView::InvalidateModelEntry(SvTreeListEntry* pEntry) +{ + if (!m_xTreeView->GetModel()->IsEnableInvalidate()) + return; + m_xTreeView->ModelHasEntryInvalidated(pEntry); +} + void SalInstanceTreeView::do_set_toggle(SvTreeListEntry* pEntry, TriState eState, int col) { assert(col >= 0 && static_cast<unsigned>(col) < pEntry->ItemCount()); @@ -3363,7 +3401,7 @@ void SalInstanceTreeView::do_set_toggle(SvTreeListEntry* pEntry, TriState eState break; } - m_xTreeView->ModelHasEntryInvalidated(pEntry); + InvalidateModelEntry(pEntry); } TriState SalInstanceTreeView::do_get_toggle(SvTreeListEntry* pEntry, int col) @@ -3802,7 +3840,7 @@ void SalInstanceTreeView::set_text(SvTreeListEntry* pEntry, const OUString& rTex assert(dynamic_cast<SvLBoxString*>(&rItem)); static_cast<SvLBoxString&>(rItem).SetText(rText); } - m_xTreeView->ModelHasEntryInvalidated(pEntry); + InvalidateModelEntry(pEntry); } void SalInstanceTreeView::set_text(int pos, const OUString& rText, int col) @@ -3822,8 +3860,7 @@ void SalInstanceTreeView::set_sensitive(SvTreeListEntry* pEntry, bool bSensitive if (rItem.GetType() == SvLBoxItemType::String) { rItem.Enable(bSensitive); - m_xTreeView->ModelHasEntryInvalidated(pEntry); - break; + InvalidateModelEntry(pEntry); } } return; @@ -3835,7 +3872,7 @@ void SalInstanceTreeView::set_sensitive(SvTreeListEntry* pEntry, bool bSensitive SvLBoxItem& rItem = pEntry->GetItem(col); rItem.Enable(bSensitive); - m_xTreeView->ModelHasEntryInvalidated(pEntry); + InvalidateModelEntry(pEntry); } void SalInstanceTreeView::set_sensitive(int pos, bool bSensitive, int col) @@ -3894,7 +3931,7 @@ void SalInstanceTreeView::set_text_emphasis(SvTreeListEntry* pEntry, bool bOn, i assert(dynamic_cast<SvLBoxString*>(&rItem)); static_cast<SvLBoxString&>(rItem).Emphasize(bOn); - m_xTreeView->ModelHasEntryInvalidated(pEntry); + InvalidateModelEntry(pEntry); } void SalInstanceTreeView::set_text_emphasis(const weld::TreeIter& rIter, bool bOn, int col) @@ -3930,7 +3967,7 @@ void SalInstanceTreeView::set_text_align(SvTreeListEntry* pEntry, double fAlign, assert(dynamic_cast<SvLBoxString*>(&rItem)); static_cast<SvLBoxString&>(rItem).Align(fAlign); - m_xTreeView->ModelHasEntryInvalidated(pEntry); + InvalidateModelEntry(pEntry); } void SalInstanceTreeView::set_text_align(const weld::TreeIter& rIter, double fAlign, int col) @@ -3995,7 +4032,7 @@ void SalInstanceTreeView::set_image(SvTreeListEntry* pEntry, const Image& rImage } m_xTreeView->SetEntryHeight(pEntry); - m_xTreeView->ModelHasEntryInvalidated(pEntry); + InvalidateModelEntry(pEntry); } void SalInstanceTreeView::set_image(int pos, const OUString& rImage, int col) @@ -4272,6 +4309,8 @@ void SalInstanceTreeView::set_selection_mode(SelectionMode eMode) void SalInstanceTreeView::all_foreach(const std::function<bool(weld::TreeIter&)>& func) { + UpdateGuard aGuard(*m_xTreeView); + SalInstanceTreeIter aVclIter(m_xTreeView->First()); while (aVclIter.iter) { |