[Libreoffice-commits] .: 2 commits - framework/inc framework/source svx/source

Caolán McNamara caolan at kemper.freedesktop.org
Tue Jun 7 09:13:17 PDT 2011


 framework/inc/services/autorecovery.hxx    |   20 ++++++++++++++
 framework/source/services/autorecovery.cxx |   40 ++++++++++++++++++++++-------
 svx/source/unodraw/recoveryui.cxx          |   19 +++++++------
 3 files changed, 61 insertions(+), 18 deletions(-)

New commits:
commit 804436f3f16ccfa48f15fd290da84c154edbca34
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Jun 7 17:05:54 2011 +0100

    Related: rhbz#652604 ensure wizard is dismissed if exception thrown

diff --git a/svx/source/unodraw/recoveryui.cxx b/svx/source/unodraw/recoveryui.cxx
index c58adb1..8396d39 100644
--- a/svx/source/unodraw/recoveryui.cxx
+++ b/svx/source/unodraw/recoveryui.cxx
@@ -42,6 +42,8 @@
 
 #include <vcl/svapp.hxx>
 
+#include <boost/scoped_ptr.hpp>
+
 //===============================================
 // const
 
@@ -312,29 +314,28 @@ void RecoveryUI::impl_doRecovery()
 
     // create all needed dialogs for this operation
     // and bind it to the used core service
-    svxdr::TabDialog4Recovery* pWizard = new svxdr::TabDialog4Recovery   (m_pParentWindow);
-    svxdr::IExtendedTabPage*   pPage1  = new svxdr::RecoveryDialog       (pWizard, pCore );
+    boost::scoped_ptr<svxdr::TabDialog4Recovery> xWizard(new svxdr::TabDialog4Recovery(m_pParentWindow));
+    svxdr::IExtendedTabPage*   pPage1  = new svxdr::RecoveryDialog(xWizard.get(), pCore );
     svxdr::IExtendedTabPage*   pPage2  = 0;
     svxdr::IExtendedTabPage*   pPage3  = 0;
     
-    pWizard->addTabPage(pPage1);
+    xWizard->addTabPage(pPage1);
     if ( !bRecoveryOnly && new_crash_pending() )
     {
-        pPage2 = new svxdr::ErrorRepWelcomeDialog(pWizard        );
-        pPage3 = new svxdr::ErrorRepSendDialog   (pWizard        );
-        pWizard->addTabPage(pPage2);
-        pWizard->addTabPage(pPage3);
+        pPage2 = new svxdr::ErrorRepWelcomeDialog(xWizard.get());
+        pPage3 = new svxdr::ErrorRepSendDialog(xWizard.get());
+        xWizard->addTabPage(pPage2);
+        xWizard->addTabPage(pPage3);
     }   
     
     // start the wizard
-    pWizard->Execute();
+    xWizard->Execute();
 
     impl_showAllRecoveredDocs();
     
     delete pPage3 ;
     delete pPage2 ;
     delete pPage1 ;
-    delete pWizard;
 
     delete_pending_crash();
 }
commit deec170473e5bb41df30919d0bfab0bf904effae
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Jun 7 17:03:52 2011 +0100

    Related: rhbz#652604 better survive exceptions thrown during autorecover

diff --git a/framework/inc/services/autorecovery.hxx b/framework/inc/services/autorecovery.hxx
index 636ad98..6c4207e 100644
--- a/framework/inc/services/autorecovery.hxx
+++ b/framework/inc/services/autorecovery.hxx
@@ -861,6 +861,26 @@ class AutoRecovery  : public  css::lang::XTypeProvider
                                                                             const ::rtl::OUString&             sEventType,
                                                                                   AutoRecovery::TDocumentInfo* pInfo     );
 
+
+        class ListenerInformer
+        {
+        private:
+            AutoRecovery &m_rRecovery;
+            sal_Int32 m_eJob;
+            bool m_bStopped;
+        public:
+            ListenerInformer(AutoRecovery &rRecovery, sal_Int32 eJob)
+                : m_rRecovery(rRecovery), m_eJob(eJob), m_bStopped(false)
+            {
+            }
+            void start();
+            void stop();
+            ~ListenerInformer()
+            {
+                stop();
+            }
+        };
+
         //---------------------------------------
 
         // TODO document me
diff --git a/framework/source/services/autorecovery.cxx b/framework/source/services/autorecovery.cxx
index efe2f17..ec60d13 100644
--- a/framework/source/services/autorecovery.cxx
+++ b/framework/source/services/autorecovery.cxx
@@ -576,6 +576,21 @@ void SAL_CALL AutoRecovery::dispatch(const css::util::URL&
         implts_dispatch(aParams);
 }
 
+void AutoRecovery::ListenerInformer::start()
+{
+    m_rRecovery.implts_informListener(m_eJob,
+        AutoRecovery::implst_createFeatureStateEvent(m_eJob, OPERATION_START, NULL));
+}
+
+void AutoRecovery::ListenerInformer::stop()
+{
+    if (m_bStopped)
+        return;
+    m_rRecovery.implts_informListener(m_eJob,
+        AutoRecovery::implst_createFeatureStateEvent(m_eJob, OPERATION_STOP, NULL));
+    m_bStopped = true;
+}
+
 //-----------------------------------------------
 void AutoRecovery::implts_dispatch(const DispatchParams& aParams)
 {
@@ -599,8 +614,8 @@ void AutoRecovery::implts_dispatch(const DispatchParams& aParams)
     implts_stopTimer();
     implts_stopListening();
 
-    implts_informListener(eJob,
-        AutoRecovery::implst_createFeatureStateEvent(eJob, OPERATION_START, NULL));
+    ListenerInformer aListenerInformer(*this, eJob);
+    aListenerInformer.start();
 
     try
     {
@@ -676,13 +691,14 @@ void AutoRecovery::implts_dispatch(const DispatchParams& aParams)
             )
             implts_cleanUpWorkingEntry(aParams);
     }
-    catch(const css::uno::RuntimeException& exRun)
-        { throw exRun; }
+    catch(const css::uno::RuntimeException&)
+    {
+        throw;
+    }
     catch(const css::uno::Exception&)
         {} // TODO better error handling
 
-    implts_informListener(eJob,
-        AutoRecovery::implst_createFeatureStateEvent(eJob, OPERATION_STOP, NULL));
+    aListenerInformer.stop();
 
     // SAFE -> ----------------------------------
     aWriteLock.lock();
@@ -1304,8 +1320,8 @@ void AutoRecovery::implts_flushConfigItem(const AutoRecovery::TDocumentInfo& rIn
                 xModify->insertByName(sID, css::uno::makeAny(xSet));
         }
     }
-    catch(const css::uno::RuntimeException& exRun)
-        { throw exRun; }
+    catch(const css::uno::RuntimeException&)
+        { throw; }
     catch(const css::uno::Exception&)
         {} // ??? can it happen that a full disc let these set of operations fail too ???
 
@@ -1627,7 +1643,13 @@ IMPL_LINK(AutoRecovery, implts_asyncDispatch, void*, EMPTYARG)
     aWriteLock.unlock();
     // <- SAFE
 
-    implts_dispatch(aParams);
+    try
+    {
+        implts_dispatch(aParams);
+    }
+    catch (...)
+    {
+    }
     return 0;
 }
 


More information about the Libreoffice-commits mailing list