include/vcl/svapp.hxx                     |    5 ++++-
 svx/source/unodraw/UnoGraphicExporter.cxx |    4 ++--
 vcl/source/app/svapp.cxx                  |    8 +++++---
 3 files changed, 11 insertions(+), 6 deletions(-)

New commits:
commit 2b2958c1b3ecfdbcd3faf3641b897efdf03b4837
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sat Feb 8 13:32:33 2025 +0500
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue Feb 11 22:26:47 2025 +0100

    tdf#165099: do not notify change listeners about temporary changes
    
    Commit bc09a4f1ce1f6a714f7827a404aa6317b503d307 (Disable subpixel AA
    in GraphicExporter::filter unconditionally, 2024-12-04)  had changed
    GraphicExporter::filter  to set application settings unconditionally,
    instead of only when AA was explicitly set. That uncovered a problem
    that the change may trigger a rebuild of sidebars;  and in slideshow
    case, it may make the rebuilt sidebars to capture the temporary view
    created for the slideshow.
    
    1. Slideshow is built; in SlideShow::StartFullscreenPresentation, it
       creates a new component with a frame,  which eventually creates a
       new sd::DrawController;
    2. Slideshow draws its slide(s); in slideshow::internal::getMetaFile,
       GraphicExporter::filter is called, which would change application
       settings;
    3. Application::SetSettings eventually trigger WindowEventHandler in
       sfx2::sidebar::SidebarController, with WindowDataChanged;
    4. SidebarController::maContextChangeUpdate is called asynchronously,
       i.e.,  after all the draw is finished;  eventually this will call
       SidebarController::UpdateConfigurations for SdSlideTransitionDeck,
       which forces rebuild of the deck;
    5. sd::SlideTransitionPane::Initialize  resets its mxView to current
       controller, which is the sd::DrawController created on step 1 for
       the slideshow;
    6. sd::SlideShow::end closes its frame, eventually disposing frame's
       controller (calling sd::DrawController::dispose);  note that this
       controller is still referenced from sidebar.
    
    After that, the sidebar interactions will crash because of unhandled
    exception thrown from DrawController::ThrowIfDisposed.
    
    Note that the change in the abovementioned commit only uncovered the
    problem; before that change it could still crash, when AA was set in
    the GraphicExporter::filter call.
    
    This change makes sure to not notify listeners in the #3 above, when
    the change of the settings is only temporary  (for the duration of a
    export). This is similar to the existing bTemporary argument that is
    already passed to SetAntiAliasing from GraphicExporter::filter. This
    allows to avoid the unwanted sidebar rebuild;  and also, this should
    improve the filter call performance. The hope is, that this wouldn't
    modify the result; but if some components, that listen to the change
    notifications, happen to affect the export,  we likely would need to
    change their behavior to always use Application::GetSettings.
    
    It seems to me, that after this change, clicking the first time on a
    transition after a slideshow will not select it.  Seems like another
    pre-existing problem;  it flickered before selection even before the
    change; likely needs a separate fix.
    
    Change-Id: Ia0ba19401ca805c2190926623c1c708cf26a313b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181288
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    (cherry picked from commit ca31eac04b10fec6bf27a801b9164ec419062763)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181300
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    (cherry picked from commit ab33bb9e3e1a3e2039715db6483e412d51a06f01)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181351
    (cherry picked from commit d9c7b214c6a040483431e9120099237072aa5bcb)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181363
    Tested-by: Michael Weghorn <m.wegh...@posteo.de>
    Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org>
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Reviewed-by: Jonathan Clark <jonat...@libreoffice.org>

diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx
index 2725642763c0..7196ed83f971 100644
--- a/include/vcl/svapp.hxx
+++ b/include/vcl/svapp.hxx
@@ -641,9 +641,12 @@ public:
      @param     rSettings       const reference to settings object used to
                                 change the application's settings.
 
+     @param     bTemporary      this is a temporary change (used in 
GraphicExporter::filter),
+                                do not notify change listeners
+
      @see OverrideSystemSettings, MergeSystemSettings, GetSettings
     */
-    static void                 SetSettings( const AllSettings& rSettings );
+    static void                 SetSettings( const AllSettings& rSettings, 
bool bTemporary = false );
 
     /** Gets the application's settings. If the application hasn't initialized
      it's settings, then it does so (lazy initialization).
diff --git a/svx/source/unodraw/UnoGraphicExporter.cxx 
b/svx/source/unodraw/UnoGraphicExporter.cxx
index 7f412c3b7110..fe59c95e5a29 100644
--- a/svx/source/unodraw/UnoGraphicExporter.cxx
+++ b/svx/source/unodraw/UnoGraphicExporter.cxx
@@ -1014,7 +1014,7 @@ sal_Bool SAL_CALL GraphicExporter::filter( const 
Sequence< PropertyValue >& aDes
             aStyleSettings.SetUseFontAAFromSystem(false);
         }
         aAllSettings.SetStyleSettings(aStyleSettings);
-        Application::SetSettings(aAllSettings);
+        Application::SetSettings(aAllSettings, /*bTemporary*/true);
         nStatus = GetGraphic( aSettings, aGraphic, bVectorType ) ? 
ERRCODE_NONE : ERRCODE_GRFILTER_FILTERERROR;
         if (aSettings.meAntiAliasing != TRISTATE_INDET)
         {
@@ -1023,7 +1023,7 @@ sal_Bool SAL_CALL GraphicExporter::filter( const 
Sequence< PropertyValue >& aDes
         }
         aStyleSettings.SetUseSubpixelAA(bUseSubpixelAA);
         aAllSettings.SetStyleSettings(aStyleSettings);
-        Application::SetSettings(aAllSettings);
+        Application::SetSettings(aAllSettings, /*bTemporary*/true);
     }
 
     if( nStatus == ERRCODE_NONE )
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index af0b1fcd683b..a3432b77d7ac 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -577,7 +577,7 @@ void Application::MergeSystemSettings( AllSettings& 
rSettings )
     }
 }
 
-void Application::SetSettings( const AllSettings& rSettings )
+void Application::SetSettings(const AllSettings& rSettings, bool bTemporary)
 {
     const SolarMutexGuard aGuard;
 
@@ -596,8 +596,10 @@ void Application::SetSettings( const AllSettings& 
rSettings )
             pSVData->mbResLocaleSet = false;
         }
         *pSVData->maAppData.mxSettings = rSettings;
-        AllSettingsFlags nChangeFlags = aOldSettings.GetChangeFlags( 
*pSVData->maAppData.mxSettings );
-        if ( bool(nChangeFlags) )
+        // Don't broadcast temporary changes
+        AllSettingsFlags nChangeFlags = bTemporary ? AllSettingsFlags::NONE
+                                                   : 
aOldSettings.GetChangeFlags(*pSVData->maAppData.mxSettings);
+        if (nChangeFlags != AllSettingsFlags::NONE)
         {
             DataChangedEvent aDCEvt( DataChangedEventType::SETTINGS, 
&aOldSettings, nChangeFlags );
 

Reply via email to