[Libreoffice-commits] core.git: sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Dec 3 22:47:04 UTC 2018


 sw/source/core/unocore/unoparagraph.cxx |    4 +++-
 sw/source/core/unocore/unotext.cxx      |    5 ++---
 sw/source/uibase/uno/unotxvw.cxx        |    5 ++++-
 3 files changed, 9 insertions(+), 5 deletions(-)

New commits:
commit dae741a2418f1d1dd35d364ec416516cc50f5054
Author:     Vasily Melenchuk <vasily.melenchuk at cib.de>
AuthorDate: Mon Dec 3 12:19:27 2018 +0300
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Mon Dec 3 23:46:41 2018 +0100

    sw uno: do not throw exceptions on getString()
    
    getString() is passive method and no reason to throw
    an exception instead of returning empty string in some
    corner situations like object is being disposed.
    
    As a compromise information about inbalid state is
    reported into log.
    
    Change-Id: Ied6ecb356ce341d44e5a2bb21fb8379257e38c31
    Reviewed-on: https://gerrit.libreoffice.org/64442
    Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>
    Tested-by: Jenkins

diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx
index c80adc0a0d72..cd87c8692d7a 100644
--- a/sw/source/core/unocore/unoparagraph.cxx
+++ b/sw/source/core/unocore/unoparagraph.cxx
@@ -1347,7 +1347,9 @@ OUString SAL_CALL SwXParagraph::getString()
     }
     else
     {
-        throw uno::RuntimeException();
+        // Seems object is being disposed or some other problem occurs.
+        // Anyway from user point of view object still exist, so on that level this is not an error
+        SAL_WARN("sw.uno", "getString() for invalid paragraph called. Returning empty string.");
     }
     return aRet;
 }
diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx
index 0657f7bc361d..e73c74e332c2 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -906,9 +906,8 @@ OUString SAL_CALL SwXText::getString()
     const uno::Reference< text::XTextCursor > xRet = CreateCursor();
     if(!xRet.is())
     {
-        uno::RuntimeException aRuntime;
-        aRuntime.Message = cInvalidObject;
-        throw aRuntime;
+        SAL_WARN("sw.uno", "cursor was not created in getString() call. Returning empty string.");
+        return OUString();
     }
     xRet->gotoEnd(true);
     return xRet->getString();
diff --git a/sw/source/uibase/uno/unotxvw.cxx b/sw/source/uibase/uno/unotxvw.cxx
index 204f8ed45447..c1fe9085ddc0 100644
--- a/sw/source/uibase/uno/unotxvw.cxx
+++ b/sw/source/uibase/uno/unotxvw.cxx
@@ -1392,7 +1392,10 @@ OUString SwXTextViewCursor::getString()
     if(m_pView)
     {
         if (!IsTextSelection( false ))
-            throw  uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
+        {
+            SAL_WARN("sw.uno", "no text selection in getString() " << static_cast<cppu::OWeakObject*>(this));
+            return uRet;
+        }
 
         ShellMode eSelMode = m_pView->GetShellMode();
         switch(eSelMode)


More information about the Libreoffice-commits mailing list