tdf#137432 only do EnableInvalidate(false) optimization when not shown

Change-Id: If7f35d19061a7a2db2e5df31227834526bbf0905
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104381
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/cui/source/options/optaboutconfig.cxx b/cui/source/options/optaboutconfig.cxx
index c6348f2..fdcef5c 100644
--- a/cui/source/options/optaboutconfig.cxx
+++ b/cui/source/options/optaboutconfig.cxx
@@ -791,6 +791,7 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, SearchHdl_Impl, weld::Button&, void)
{
    weld::WaitObject aWait(m_xDialog.get());

    m_xPrefBox->hide();
    m_xPrefBox->clear();
    m_xPrefBox->freeze();

@@ -844,6 +845,7 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, SearchHdl_Impl, weld::Button&, void)
        m_xPrefBox->expand_row(rEntry);
        return false;
    });
    m_xPrefBox->show();
}

void CuiAboutConfigTabPage::InsertEntry(const prefBoxEntry& rEntry)
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 29ecc5d..a1e533e 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -3311,7 +3311,8 @@ namespace
        UpdateGuard(SvTabListBox& rTreeView)
            : m_rTreeView(rTreeView)
            , m_bOrigUpdate(m_rTreeView.IsUpdateMode())
            , m_bOrigEnableInvalidate(m_rTreeView.GetModel()->IsEnableInvalidate())
            // tdf#137432 only do the EnableInvalidate(false) optimization if the widget is currently hidden
            , m_bOrigEnableInvalidate(!m_rTreeView.IsVisible() && m_rTreeView.GetModel()->IsEnableInvalidate())
        {
            if (m_bOrigUpdate)
                m_rTreeView.SetUpdateMode(false);
@@ -3321,10 +3322,10 @@ namespace

        ~UpdateGuard()
        {
            if (m_bOrigUpdate)
                m_rTreeView.SetUpdateMode(true);
            if (m_bOrigEnableInvalidate)
                m_rTreeView.GetModel()->EnableInvalidate(true);
            if (m_bOrigUpdate)
                m_rTreeView.SetUpdateMode(true);
        }
    };
}