[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-1+backports' - sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Dec 5 15:55:38 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 3afae09e96051f3bdf05b7f5fb7b5994d3a37a79
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: Wed Dec 5 16:55:12 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
    (cherry picked from commit dae741a2418f1d1dd35d364ec416516cc50f5054)
    Reviewed-on: https://gerrit.libreoffice.org/64628
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx
index f7a76e902013..1cbc8671104d 100644
--- a/sw/source/core/unocore/unoparagraph.cxx
+++ b/sw/source/core/unocore/unoparagraph.cxx
@@ -1342,7 +1342,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 5ecc6fbf399b..4f2b1c0c6c90 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -902,9 +902,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 1348a5fde2bf..42c709ec7db9 100644
--- a/sw/source/uibase/uno/unotxvw.cxx
+++ b/sw/source/uibase/uno/unotxvw.cxx
@@ -1365,7 +1365,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