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 198d4c66f882b8aea7bf4e49b2a3871ba88f3e55
Author:     Szymon Kłos <[email protected]>
AuthorDate: Wed Oct 29 12:09:17 2025 +0000
Commit:     Szymon Kłos <[email protected]>
CommitDate: Thu Oct 30 07:07:25 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
    Tested-by: Caolán McNamara <[email protected]>
    Reviewed-by: Caolán McNamara <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[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 421fa343d7b0..ee13eb00fdd8 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 70b12025ab46..166deb192780 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&
     , mrBase(rBase)
     , mxSidebar(std::move(xSidebar))
     , maIconViewId(rIconViewId)
+    , maUpdateTask(*this)
 {
     mxPreviewIconView->connect_item_activated(LINK(this, MasterPagesSelector, 
MasterPageSelected));
     mxPreviewIconView->connect_mouse_press(LINK(this, MasterPagesSelector, 
MousePressHdl));
@@ -69,6 +70,7 @@ MasterPagesSelector::MasterPagesSelector(weld::Widget* 
pParent, SdDrawDocument&
 
     Link<MasterPageContainerChangeEvent&,void> aChangeListener 
(LINK(this,MasterPagesSelector,ContainerChangeListener));
     mpContainer->AddChangeListener(aChangeListener);
+    maUpdateTask.Start();
 }
 
 // Notebookbar
@@ -82,6 +84,7 @@ MasterPagesSelector::MasterPagesSelector(weld::Widget* 
pParent, SdDrawDocument&
     , mrDocument(rDocument)
     , mrBase(rBase)
     , maIconViewId(rIconViewId)
+    , maUpdateTask(*this)
 {
     mxPreviewIconView->connect_item_activated(LINK(this, MasterPagesSelector, 
MasterPageSelected));
     mxPreviewIconView->connect_mouse_press(LINK(this, MasterPagesSelector, 
MousePressHdl));
@@ -89,6 +92,7 @@ MasterPagesSelector::MasterPagesSelector(weld::Widget* 
pParent, SdDrawDocument&
 
     Link<MasterPageContainerChangeEvent&,void> aChangeListener 
(LINK(this,MasterPagesSelector,ContainerChangeListener));
     mpContainer->AddChangeListener(aChangeListener);
+    maUpdateTask.Start();
 }
 
 
@@ -105,6 +109,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 8bb65d068150..89584ad202fa 100644
--- a/sd/source/ui/sidebar/MasterPagesSelector.hxx
+++ b/sd/source/ui/sidebar/MasterPagesSelector.hxx
@@ -26,6 +26,7 @@
 #include <vcl/vclptr.hxx>
 #include <vcl/virdev.hxx>
 #include <vcl/weld.hxx>
+#include <vcl/idle.hxx>
 #include <sfx2/sidebar/ILayoutableWindow.hxx>
 #include <sfx2/sidebar/PanelLayout.hxx>
 
@@ -48,6 +49,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,
@@ -160,6 +176,7 @@ protected:
 private:
     css::uno::Reference<css::ui::XSidebar> mxSidebar;
     OUString maIconViewId;
+    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