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

Change-Id: If7f35d19061a7a2db2e5df31227834526bbf0905
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104334
Tested-by: Jenkins
Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
diff --git a/cui/source/options/optaboutconfig.cxx b/cui/source/options/optaboutconfig.cxx
index 79a75bd..7f5e73a 100644
--- a/cui/source/options/optaboutconfig.cxx
+++ b/cui/source/options/optaboutconfig.cxx
@@ -792,6 +792,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();

@@ -845,6 +846,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 3108ff5..acd296c 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -3195,7 +3195,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);
@@ -3205,10 +3206,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);
        }
    };
}