[Libreoffice-commits] core.git: basctl/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Wed Feb 12 16:29:24 UTC 2020


 basctl/source/basicide/bastype2.cxx |   14 ++++++++++++--
 basctl/source/basicide/bastype3.cxx |    9 +++++++++
 basctl/source/inc/bastype2.hxx      |    1 +
 3 files changed, 22 insertions(+), 2 deletions(-)

New commits:
commit d81489fe40f93925296d8cf5b49e74607ab833cf
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Feb 11 15:53:17 2020 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Feb 12 17:28:50 2020 +0100

    only freeze/thaw if we have to
    
    because gtk will relayout and things jump around confusingly
    and unnecessarily
    
    Change-Id: I817e803f8ad7e523e5855326fc097f8798ddb679
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88526
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/basctl/source/basicide/bastype2.cxx b/basctl/source/basicide/bastype2.cxx
index 378700bb5325..642b5c7adaea 100644
--- a/basctl/source/basicide/bastype2.cxx
+++ b/basctl/source/basicide/bastype2.cxx
@@ -851,6 +851,7 @@ SbTreeListBox::SbTreeListBox(std::unique_ptr<weld::TreeView> xControl, weld::Win
     : m_xControl(std::move(xControl))
     , m_xIter(m_xControl->make_iterator())
     , m_pTopLevel(pTopLevel)
+    , m_bFreezeOnFirstAddRemove(false)
     , m_aNotifier(*this)
 {
     m_xControl->connect_row_activated(LINK(this, SbTreeListBox, OpenCurrentHdl));
@@ -880,7 +881,6 @@ void SbTreeListBox::ScanEntry( const ScriptDocument& rDocument, LibraryLocation
     // can be called multiple times for updating!
 
     // actually test if basic's in the tree already?!
-    m_xControl->freeze();
     // level 1: BasicManager (application, document, ...)
     bool bDocumentRootEntry = FindRootEntry(rDocument, eLocation, *m_xIter);
     if (bDocumentRootEntry && m_xControl->get_row_expanded(*m_xIter))
@@ -891,7 +891,6 @@ void SbTreeListBox::ScanEntry( const ScriptDocument& rDocument, LibraryLocation
         OUString aImage(GetRootEntryBitmaps(rDocument));
         AddEntry(aRootName, aImage, nullptr, true, std::make_unique<DocumentEntry>(rDocument, eLocation));
     }
-    m_xControl->thaw();
 }
 
 void SbTreeListBox::ImpCreateLibEntries(const weld::TreeIter& rIter, const ScriptDocument& rDocument, LibraryLocation eLocation)
@@ -1259,6 +1258,12 @@ void SbTreeListBox::UpdateEntries()
 // Removes the entry from the tree.
 void SbTreeListBox::RemoveEntry(const weld::TreeIter& rIter)
 {
+    if (m_bFreezeOnFirstAddRemove)
+    {
+        m_xControl->freeze();
+        m_bFreezeOnFirstAddRemove = false;
+    }
+
     // removing the associated user data
     Entry* pBasicEntry = reinterpret_cast<Entry*>(m_xControl->get_id(rIter).toInt64());
     delete pBasicEntry;
@@ -1329,6 +1334,11 @@ void SbTreeListBox::AddEntry(
     std::unique_ptr<Entry>&& rUserData,
     weld::TreeIter* pRet)
 {
+    if (m_bFreezeOnFirstAddRemove)
+    {
+        m_xControl->freeze();
+        m_bFreezeOnFirstAddRemove= false;
+    }
     OUString sId(OUString::number(reinterpret_cast<sal_uInt64>(rUserData.release())));
     m_xControl->insert(pParent, -1, &rText, &sId, nullptr, nullptr, &rImage, bChildrenOnDemand, pRet);
 }
diff --git a/basctl/source/basicide/bastype3.cxx b/basctl/source/basicide/bastype3.cxx
index fec708b6f7f0..93fb1525d473 100644
--- a/basctl/source/basicide/bastype3.cxx
+++ b/basctl/source/basicide/bastype3.cxx
@@ -246,6 +246,10 @@ void TreeListBox::ScanAllEntries()
 
 void SbTreeListBox::ScanAllEntries()
 {
+    // instead of always freezing, freeze on the first add/remove, which keeps gtk
+    // from relayouting the tree if its not necessary
+    m_bFreezeOnFirstAddRemove = true;
+
     ScanEntry( ScriptDocument::getApplicationScriptDocument(), LIBRARY_LOCATION_USER );
     ScanEntry( ScriptDocument::getApplicationScriptDocument(), LIBRARY_LOCATION_SHARE );
 
@@ -255,6 +259,11 @@ void SbTreeListBox::ScanAllEntries()
         if ( doc.isAlive() )
             ScanEntry(doc, LIBRARY_LOCATION_DOCUMENT);
     }
+
+    if (!m_bFreezeOnFirstAddRemove)
+        m_xControl->thaw(); // m_bFreezeOnFirstAddRemove was changed, so control was frozen
+    else
+        m_bFreezeOnFirstAddRemove = false;
 }
 
 SbxVariable* SbTreeListBox::FindVariable(const weld::TreeIter* pEntry)
diff --git a/basctl/source/inc/bastype2.hxx b/basctl/source/inc/bastype2.hxx
index 720d3156ac00..5e22375bd0e9 100644
--- a/basctl/source/inc/bastype2.hxx
+++ b/basctl/source/inc/bastype2.hxx
@@ -245,6 +245,7 @@ private:
     std::unique_ptr<weld::TreeView> m_xControl;
     std::unique_ptr<weld::TreeIter> m_xIter;
     weld::Window* m_pTopLevel;
+    bool m_bFreezeOnFirstAddRemove;
     BrowseMode nMode;
     DocumentEventNotifier m_aNotifier;
     void            SetEntryBitmaps(const weld::TreeIter& rIter, const OUString& rImage);


More information about the Libreoffice-commits mailing list