sd/source/ui/sidebar/AllMasterPagesSelector.cxx     |    4 ----
 sd/source/ui/sidebar/CurrentMasterPagesSelector.cxx |    2 --
 sd/source/ui/sidebar/MasterPagesSelector.cxx        |    5 +++++
 sd/source/ui/sidebar/MasterPagesSelector.hxx        |   17 +++++++++++++++++
 sd/source/ui/sidebar/RecentMasterPagesSelector.cxx  |    2 --
 5 files changed, 22 insertions(+), 8 deletions(-)

New commits:
commit bf390cbecc4e88ccaf1aabcc9f1df9900faa580d
Author:     Szymon Kłos <[email protected]>
AuthorDate: Wed Oct 29 12:09:17 2025 +0000
Commit:     Szymon Kłos <[email protected]>
CommitDate: Tue Dec 30 11:46:49 2025 +0100

    sd: delay init of master pages widget
    
    - similar to commit 522bde9470bbb321813fa5f1ca8e3c2ebb1bb5cc
    Update styles previews in Idle
    - avoid rendering previews just on creation of the notebookbar
    - we prefer to load presentation first, then start to fill content
    
    Change-Id: I1d2a11e841f82b5695d995495543f8cc3eeec8d7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193147
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196324
    Tested-by: Jenkins
    Reviewed-by: Szymon Kłos <[email protected]>

diff --git a/sd/source/ui/sidebar/AllMasterPagesSelector.cxx 
b/sd/source/ui/sidebar/AllMasterPagesSelector.cxx
index e966d2a8a851..4b10d40af750 100644
--- a/sd/source/ui/sidebar/AllMasterPagesSelector.cxx
+++ b/sd/source/ui/sidebar/AllMasterPagesSelector.cxx
@@ -91,7 +91,6 @@ std::unique_ptr<PanelLayout> AllMasterPagesSelector::Create (
             rViewShellBase,
             pContainer,
             rxSidebar));
-    xSelector->LateInit();
     xSelector->SetHelpId(HID_SD_TASK_PANE_PREVIEW_ALL);
 
     return xSelector;
@@ -112,7 +111,6 @@ std::unique_ptr<PanelLayout> AllMasterPagesSelector::Create 
(
             *pDocument,
             rViewShellBase,
             pContainer));
-    xSelector->LateInit();
     xSelector->SetHelpId(HID_SD_TASK_PANE_PREVIEW_ALL);
 
     return xSelector;
@@ -127,7 +125,6 @@ AllMasterPagesSelector::AllMasterPagesSelector(
                           u"masterpageall_icons"_ustr)
     , mpSortedMasterPages(new SortedMasterPageDescriptorList())
 {
-    MasterPagesSelector::Fill();
 }
 
 AllMasterPagesSelector::AllMasterPagesSelector(
@@ -138,7 +135,6 @@ AllMasterPagesSelector::AllMasterPagesSelector(
                           u"masterpageall_icons"_ustr)
     , mpSortedMasterPages(new SortedMasterPageDescriptorList())
 {
-    MasterPagesSelector::Fill();
 }
 
 
diff --git a/sd/source/ui/sidebar/CurrentMasterPagesSelector.cxx 
b/sd/source/ui/sidebar/CurrentMasterPagesSelector.cxx
index 3efa26e7a34e..aa222e81766a 100644
--- a/sd/source/ui/sidebar/CurrentMasterPagesSelector.cxx
+++ b/sd/source/ui/sidebar/CurrentMasterPagesSelector.cxx
@@ -54,7 +54,6 @@ std::unique_ptr<PanelLayout> 
CurrentMasterPagesSelector::Create (
             rViewShellBase,
             pContainer,
             rxSidebar));
-    xSelector->LateInit();
     xSelector->SetHelpId( HID_SD_TASK_PANE_PREVIEW_CURRENT );
 
     return xSelector;
@@ -92,7 +91,6 @@ CurrentMasterPagesSelector::~CurrentMasterPagesSelector()
 void CurrentMasterPagesSelector::LateInit()
 {
     MasterPagesSelector::LateInit();
-    MasterPagesSelector::Fill();
     if (mrDocument.GetDocSh() != nullptr)
     {
         StartListening(*mrDocument.GetDocSh());
diff --git a/sd/source/ui/sidebar/MasterPagesSelector.cxx 
b/sd/source/ui/sidebar/MasterPagesSelector.cxx
index dce62ce61807..685c128cc479 100644
--- a/sd/source/ui/sidebar/MasterPagesSelector.cxx
+++ b/sd/source/ui/sidebar/MasterPagesSelector.cxx
@@ -62,6 +62,7 @@ MasterPagesSelector::MasterPagesSelector(weld::Widget* 
pParent, SdDrawDocument&
     , mrDocument(rDocument)
     , mrBase(rBase)
     , mxSidebar(std::move(xSidebar))
+    , maUpdateTask(*this)
 {
     mxPreviewIconView->connect_item_activated(LINK(this, MasterPagesSelector, 
MasterPageSelected));
     mxPreviewIconView->connect_command(LINK(this, MasterPagesSelector, 
CommandHdl));
@@ -69,6 +70,7 @@ MasterPagesSelector::MasterPagesSelector(weld::Widget* 
pParent, SdDrawDocument&
 
     Link<MasterPageContainerChangeEvent&,void> aChangeListener 
(LINK(this,MasterPagesSelector,ContainerChangeListener));
     mpContainer->AddChangeListener(aChangeListener);
+    maUpdateTask.Start();
 }
 
 // Notebookbar
@@ -81,6 +83,7 @@ MasterPagesSelector::MasterPagesSelector(weld::Widget* 
pParent, SdDrawDocument&
     , mxPreviewIconView(m_xBuilder->weld_icon_view(rIconViewId))
     , mrDocument(rDocument)
     , mrBase(rBase)
+    , maUpdateTask(*this)
 {
     mxPreviewIconView->connect_item_activated(LINK(this, MasterPagesSelector, 
MasterPageSelected));
     mxPreviewIconView->connect_command(LINK(this, MasterPagesSelector, 
CommandHdl));
@@ -88,6 +91,7 @@ MasterPagesSelector::MasterPagesSelector(weld::Widget* 
pParent, SdDrawDocument&
 
     Link<MasterPageContainerChangeEvent&,void> aChangeListener 
(LINK(this,MasterPagesSelector,ContainerChangeListener));
     mpContainer->AddChangeListener(aChangeListener);
+    maUpdateTask.Start();
 }
 
 
@@ -104,6 +108,7 @@ MasterPagesSelector::~MasterPagesSelector()
 
 void MasterPagesSelector::LateInit()
 {
+    Fill();
 }
 
 void MasterPagesSelector::UpdateLocks (const ItemList& rItemList)
diff --git a/sd/source/ui/sidebar/MasterPagesSelector.hxx 
b/sd/source/ui/sidebar/MasterPagesSelector.hxx
index bfcab7eb23aa..a170bf16b5ae 100644
--- a/sd/source/ui/sidebar/MasterPagesSelector.hxx
+++ b/sd/source/ui/sidebar/MasterPagesSelector.hxx
@@ -27,6 +27,7 @@
 #include <vcl/virdev.hxx>
 #include <vcl/weld/IconView.hxx>
 #include <vcl/weld/weld.hxx>
+#include <vcl/idle.hxx>
 #include <sfx2/sidebar/ILayoutableWindow.hxx>
 #include <sfx2/sidebar/PanelLayout.hxx>
 
@@ -49,6 +50,21 @@ namespace sd::sidebar {
 class MasterPagesSelector : public PanelLayout
                           , public sfx2::sidebar::ILayoutableWindow
 {
+    class UpdateTask final : public Idle
+    {
+        MasterPagesSelector& m_rContainer;
+
+    public:
+        UpdateTask(MasterPagesSelector& rStylesList)
+            : Idle("MasterPagesUpdateTask")
+            , m_rContainer(rStylesList)
+        {
+            SetPriority(TaskPriority::DEFAULT_IDLE);
+        }
+
+        virtual void Invoke() override { m_rContainer.LateInit(); }
+    };
+
 public:
     // Sidebar
     MasterPagesSelector(weld::Widget* pParent, SdDrawDocument& rDocument, 
ViewShellBase& rBase,
@@ -158,6 +174,7 @@ protected:
 
 private:
     css::uno::Reference<css::ui::XSidebar> mxSidebar;
+    UpdateTask maUpdateTask;
 
     /** The offset between ValueSet index and MasterPageContainer::Token
         last seen.  This value is used heuristically to speed up the lookup
diff --git a/sd/source/ui/sidebar/RecentMasterPagesSelector.cxx 
b/sd/source/ui/sidebar/RecentMasterPagesSelector.cxx
index 0917a46712c4..f541834436c2 100644
--- a/sd/source/ui/sidebar/RecentMasterPagesSelector.cxx
+++ b/sd/source/ui/sidebar/RecentMasterPagesSelector.cxx
@@ -45,7 +45,6 @@ std::unique_ptr<PanelLayout> 
RecentMasterPagesSelector::Create (
             rViewShellBase,
             pContainer,
             rxSidebar));
-    xSelector->LateInit();
     xSelector->SetHelpId(HID_SD_TASK_PANE_PREVIEW_RECENT);
 
     return xSelector;
@@ -71,7 +70,6 @@ void RecentMasterPagesSelector::LateInit()
 {
     MasterPagesSelector::LateInit();
 
-    MasterPagesSelector::Fill();
     RecentlyUsedMasterPages::Instance().AddEventListener (
         LINK(this,RecentMasterPagesSelector,MasterPageListListener));
 }

Reply via email to