sd/source/console/PresenterScreen.cxx    |   28 +++++++++++++++++++++++++---
 sd/source/console/PresenterScreen.hxx    |    3 +++
 sd/source/ui/slideshow/slideshowimpl.cxx |   17 ++++++++++++++---
 3 files changed, 42 insertions(+), 6 deletions(-)

New commits:
commit 8caddb0d579030167791cb1c6d07bc28a3b35b49
Author:     Armin Le Grand (allotropia) <armin.le.grand.ext...@allotropia.de>
AuthorDate: Tue Mar 26 18:35:21 2024 +0100
Commit:     Armin Le Grand <armin.le.gr...@me.com>
CommitDate: Wed Mar 27 10:32:14 2024 +0100

    IASS: Fix crash with PresenterConsole
    
    When being in IASS mode and adding e.g. an effect to
    a Shape (or anything else that triggers a preview)
    and the PresenterConsole being active, we got a
    crash. That happend due to the PresenterConsole
    being initialized *twice* due to interpreting that
    preview as SlideShow start. It also closed due to
    interpreting the preview end as SlideShow end. The
    next SlideShow end then bites the dust in an already
    messed up situation.
    To solve this, SlideshowImpl::startShowImpl now only
    uses NotifyDocumentEvent "OnStartPresentation" when
    this is not a SlideShow startup.
    I also secured PresenterScreen using a local bool
    to remember if it is initialized to avoid when that
    would be done twice (also used for shutdown).
    
    Change-Id: Ice588e0783fd39ec46d90a40affcaf2f789df8ec
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165356
    Tested-by: Jenkins
    Reviewed-by: Armin Le Grand <armin.le.gr...@me.com>

diff --git a/sd/source/console/PresenterScreen.cxx 
b/sd/source/console/PresenterScreen.cxx
index 690a07f8b67c..2cbd612ff357 100644
--- a/sd/source/console/PresenterScreen.cxx
+++ b/sd/source/console/PresenterScreen.cxx
@@ -240,9 +240,17 @@ void SAL_CALL PresenterScreenListener::disposing (const 
css::lang::EventObject&)
 PresenterScreen::PresenterScreen (
     const Reference<XComponentContext>& rxContext,
     css::uno::Reference<css::frame::XModel2> xModel)
-    : PresenterScreenInterfaceBase(m_aMutex),
-      mxModel(std::move(xModel)),
-      mxContextWeak(rxContext)
+: PresenterScreenInterfaceBase(m_aMutex)
+, mxModel(std::move(xModel))
+, mxController()
+, mxConfigurationControllerWeak()
+, mxContextWeak(rxContext)
+, mpPresenterController()
+, mxSavedConfiguration()
+, mpPaneContainer()
+, mxPaneFactory()
+, mxViewFactory()
+, mbIsInitialized(false)
 {
 }
 
@@ -303,6 +311,10 @@ void SAL_CALL PresenterScreen::disposing (const 
lang::EventObject& /*rEvent*/)
 
 void PresenterScreen::InitializePresenterScreen()
 {
+    // IASS: already initialized (may even assert here?)
+    if (mbIsInitialized)
+        return;
+
     try
     {
         Reference<XComponentContext> xContext (mxContextWeak);
@@ -388,6 +400,9 @@ void PresenterScreen::InitializePresenterScreen()
     catch (const Exception&)
     {
     }
+
+    // IASS: Remember we are initialized
+    mbIsInitialized = true;
 }
 
 void PresenterScreen::SwitchMonitors()
@@ -545,6 +560,10 @@ Reference<drawing::framework::XResourceId> 
PresenterScreen::GetMainPaneId (
 
 void PresenterScreen::RequestShutdownPresenterScreen()
 {
+    // IASS: only cleanup when we are initialized
+    if (!mbIsInitialized)
+        return;
+
     // Restore the configuration that was active before the presenter screen
     // has been activated.  Now, that the presenter screen is displayed in
     // its own top level window this probably not necessary, but one never 
knows.
@@ -567,6 +586,9 @@ void PresenterScreen::RequestShutdownPresenterScreen()
             [xSelf=std::move(xSelf)](bool){ return 
xSelf->ShutdownPresenterScreen(); });
         xCC->update();
     }
+
+    // IASS: reset to non-initialized
+    mbIsInitialized = false;
 }
 
 void PresenterScreen::ShutdownPresenterScreen()
diff --git a/sd/source/console/PresenterScreen.hxx 
b/sd/source/console/PresenterScreen.hxx
index 0445311b9603..430384a45c6d 100644
--- a/sd/source/console/PresenterScreen.hxx
+++ b/sd/source/console/PresenterScreen.hxx
@@ -139,6 +139,9 @@ private:
     css::uno::Reference<css::drawing::framework::XResourceFactory> 
mxPaneFactory;
     css::uno::Reference<css::drawing::framework::XResourceFactory> 
mxViewFactory;
 
+    // IASS: Flag to note if InitializePresenterScreen() was executed
+    bool mbIsInitialized;
+
     class ViewDescriptor
     {
     public:
diff --git a/sd/source/ui/slideshow/slideshowimpl.cxx 
b/sd/source/ui/slideshow/slideshowimpl.cxx
index d06f867d994c..74d9ac4b0e6f 100644
--- a/sd/source/ui/slideshow/slideshowimpl.cxx
+++ b/sd/source/ui/slideshow/slideshowimpl.cxx
@@ -647,6 +647,8 @@ void SlideshowImpl::disposing(std::unique_lock<std::mutex>&)
 #ifdef ENABLE_SDREMOTE
     RemoteServer::presentationStopped();
 #endif
+    // IASS: This is the central methodology to 'steer' the
+    // PresenterConsole - in this case, to shut it down
     if( mxShow.is() && mpDoc )
         NotifyDocumentEvent(
             *mpDoc,
@@ -1344,9 +1346,18 @@ bool SlideshowImpl::startShowImpl( const Sequence< 
beans::PropertyValue >& aProp
         mxListenerProxy.set( new SlideShowListenerProxy( this, mxShow ) );
         mxListenerProxy->addAsSlideShowListener();
 
-        NotifyDocumentEvent(
-            *mpDoc,
-            "OnStartPresentation");
+        // IASS: Do only startup the PresenterConsole if this is not
+        // the SlideShow Preview mode (else would be double)
+        if (!mbInterActiveSetup)
+        {
+            // IASS: This is the central methodology to 'steer' the
+            // PresenterConsole - in this case, to start it up and make
+            // it visible (if activated)
+            NotifyDocumentEvent(
+                *mpDoc,
+                "OnStartPresentation");
+        }
+
         displaySlideIndex( mpSlideController->getStartSlideIndex() );
 
         return true;

Reply via email to