Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/3420

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/20/3420/1

rhbz#867808 Do not throw RuntimeException by pointer

(cherry picked from commit e46564a0a6a74da90785a1b910d33e2b5bfdcfd9, plus
63b4633cf7b0da9eba63e752cec72cb10ed9d93e "Related: rhbz#867808 if one person
threw by pointer..." and 336353a87e6003e685aab87ea74a158546e1f297 "Related
rhbz#867808: More apparently bogus 'throw new ...' in C++ code")
Conflicts:
        bridges/test/java_uno/nativethreadpool/testnativethreadpoolclient.cxx
        bridges/test/java_uno/nativethreadpool/testnativethreadpoolserver.cxx
        sdext/source/presenter/PresenterController.cxx
        stoc/source/registry_tdprovider/functiondescription.cxx
        stoc/source/registry_tdprovider/methoddescription.cxx
        toolkit/source/awt/vclxwindow1.cxx

Change-Id: I22b7d3d642e7ee0488d6b726a331d328065bbee7
---
M bridges/test/java_uno/nativethreadpool/testnativethreadpoolclient.cxx
M bridges/test/java_uno/nativethreadpool/testnativethreadpoolserver.cxx
M i18npool/source/transliteration/transliteration_Numeric.cxx
M sdext/source/presenter/PresenterController.cxx
M stoc/source/registry_tdprovider/functiondescription.cxx
M stoc/source/registry_tdprovider/methoddescription.cxx
M testtools/source/bridgetest/cli/cli_cpp_bridgetest.cxx
M toolkit/source/awt/stylesettings.cxx
M toolkit/source/awt/vclxwindow1.cxx
9 files changed, 20 insertions(+), 22 deletions(-)



diff --git a/bridges/test/java_uno/nativethreadpool/testnativethreadpoolclient.cxx 
b/bridges/test/java_uno/nativethreadpool/testnativethreadpoolclient.cxx
index 4571a17..d5b3b65 100644
--- a/bridges/test/java_uno/nativethreadpool/testnativethreadpoolclient.cxx
+++ b/bridges/test/java_uno/nativethreadpool/testnativethreadpoolclient.cxx
@@ -85,7 +85,7 @@
     css::uno::Reference< css::lang::XMultiComponentFactory > factory(
         context->getServiceManager());
     if (!factory.is()) {
-        throw new css::uno::RuntimeException(
+        throw css::uno::RuntimeException(
             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "no component context service manager" )),
             static_cast< cppu::OWeakObject * >(this));
     }
@@ -105,7 +105,7 @@
     }
     relay->start(this);
     if (!data.setData(reinterpret_cast< void * >(12345))) {
-        throw new css::uno::RuntimeException(
+        throw css::uno::RuntimeException(
             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "osl::ThreadData::setData failed" )),
             static_cast< cppu::OWeakObject * >(this));
     }
diff --git a/bridges/test/java_uno/nativethreadpool/testnativethreadpoolserver.cxx 
b/bridges/test/java_uno/nativethreadpool/testnativethreadpoolserver.cxx
index 0e6898b..c80355e 100644
--- a/bridges/test/java_uno/nativethreadpool/testnativethreadpoolserver.cxx
+++ b/bridges/test/java_uno/nativethreadpool/testnativethreadpoolserver.cxx
@@ -74,7 +74,7 @@
     css::uno::Reference< css::lang::XMultiComponentFactory > factory(
         context->getServiceManager());
     if (!factory.is()) {
-        throw new css::uno::RuntimeException(
+        throw css::uno::RuntimeException(
             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "no component context service manager" )),
             static_cast< cppu::OWeakObject * >(this));
     }
diff --git a/i18npool/source/transliteration/transliteration_Numeric.cxx 
b/i18npool/source/transliteration/transliteration_Numeric.cxx
index 3156a4c..de7eab5 100644
--- a/i18npool/source/transliteration/transliteration_Numeric.cxx
+++ b/i18npool/source/transliteration/transliteration_Numeric.cxx
@@ -47,21 +47,21 @@
 transliteration_Numeric::folding( const OUString& /*inStr*/, sal_Int32 /*startPos*/, sal_Int32 
/*nCount*/, Sequence< sal_Int32 >& /*offset*/ )
         throw(RuntimeException)
 {
-        throw (new RuntimeException());
+        throw RuntimeException();
 }
 
 sal_Bool SAL_CALL
 transliteration_Numeric::equals( const OUString& /*str1*/, sal_Int32 /*pos1*/, sal_Int32 
/*nCount1*/, sal_Int32& /*nMatch1*/, const OUString& /*str2*/, sal_Int32 /*pos2*/, sal_Int32 
/*nCount2*/, sal_Int32& /*nMatch2*/ )
         throw(RuntimeException)
 {
-        throw (new RuntimeException());
+        throw RuntimeException();
 }
 
 Sequence< OUString > SAL_CALL
 transliteration_Numeric::transliterateRange( const OUString& /*str1*/, const OUString& /*str2*/ )
         throw(RuntimeException)
 {
-        throw (new RuntimeException());
+        throw RuntimeException();
 }
 
 
diff --git a/sdext/source/presenter/PresenterController.cxx 
b/sdext/source/presenter/PresenterController.cxx
index 2b1c3e4..0321b10 100644
--- a/sdext/source/presenter/PresenterController.cxx
+++ b/sdext/source/presenter/PresenterController.cxx
@@ -127,7 +127,7 @@
     OSL_ASSERT(mxController.is());
 
     if ( ! mxSlideShowController.is())
-        throw new lang::IllegalArgumentException(
+        throw lang::IllegalArgumentException(
             A2S("missing slide show controller"),
             static_cast<XWeak*>(this),
             2);
diff --git a/stoc/source/registry_tdprovider/functiondescription.cxx 
b/stoc/source/registry_tdprovider/functiondescription.cxx
index 2056b8e..931efd4 100644
--- a/stoc/source/registry_tdprovider/functiondescription.cxx
+++ b/stoc/source/registry_tdprovider/functiondescription.cxx
@@ -82,7 +82,7 @@
         try {
             any = m_manager->getByHierarchicalName(name);
         } catch (const css::container::NoSuchElementException & e) {
-            throw new css::uno::RuntimeException(
+            throw css::uno::RuntimeException(
                 (rtl::OUString(
                     RTL_CONSTASCII_USTRINGPARAM(
                         "com.sun.star.container.NoSuchElementException: "))
@@ -92,7 +92,7 @@
         if (!(any >>= exceptions[i])
             || exceptions[i]->getTypeClass() != css::uno::TypeClass_EXCEPTION)
         {
-            throw new css::uno::RuntimeException(
+            throw css::uno::RuntimeException(
                 (rtl::OUString(
                     RTL_CONSTASCII_USTRINGPARAM("not an exception type: "))
                  + name),
diff --git a/stoc/source/registry_tdprovider/methoddescription.cxx 
b/stoc/source/registry_tdprovider/methoddescription.cxx
index bf5cb56..58525c0 100644
--- a/stoc/source/registry_tdprovider/methoddescription.cxx
+++ b/stoc/source/registry_tdprovider/methoddescription.cxx
@@ -101,7 +101,7 @@
             m_manager->getByHierarchicalName(m_typeName),
             css::uno::UNO_QUERY_THROW);
     } catch (const css::container::NoSuchElementException & e) {
-        throw new css::uno::RuntimeException(
+        throw css::uno::RuntimeException(
             (rtl::OUString(
                 RTL_CONSTASCII_USTRINGPARAM(
                     "com.sun.star.container.NoSuchElementException: "))
diff --git a/testtools/source/bridgetest/cli/cli_cpp_bridgetest.cxx 
b/testtools/source/bridgetest/cli/cli_cpp_bridgetest.cxx
index b1850d7..4b93eaf 100644
--- a/testtools/source/bridgetest/cli/cli_cpp_bridgetest.cxx
+++ b/testtools/source/bridgetest/cli/cli_cpp_bridgetest.cxx
@@ -808,7 +808,7 @@
        bRet = performQueryForUnknownType( xLBT ) && bRet;
         if (! bRet)
         {
-            throw new unoidl::com::sun::star::uno::RuntimeException(
+            throw unoidl::com::sun::star::uno::RuntimeException(
                 new String("error: test failed!"), 0);
         }
     }
@@ -828,7 +828,7 @@
         {
             if (args->Length < 1)
             {
-                throw new RuntimeException(
+                throw RuntimeException(
                     "missing argument for bridgetest!", this );
             }
             Object* test_obj =
@@ -855,7 +855,7 @@
             s->Append(exc->GetType()->Name);
             s->Append(S"\n Message: ");
             s->Append(exc->Message);
-            throw new unoidl::com::sun::star::uno::RuntimeException(
+            throw unoidl::com::sun::star::uno::RuntimeException(
                 s->ToString(), 0);
         }
     }
diff --git a/toolkit/source/awt/stylesettings.cxx b/toolkit/source/awt/stylesettings.cxx
index 0175382..97b8a9a 100644
--- a/toolkit/source/awt/stylesettings.cxx
+++ b/toolkit/source/awt/stylesettings.cxx
@@ -126,7 +126,7 @@
     {
         Window* pWindow = i_rOwningWindow.GetWindow();
         if ( !pWindow )
-            throw new RuntimeException();
+            throw RuntimeException();
         pWindow->AddEventListener( LINK( m_pData.get(), WindowStyleSettings_Data, OnWindowEvent ) 
);
     }
 
diff --git a/toolkit/source/awt/vclxwindow1.cxx b/toolkit/source/awt/vclxwindow1.cxx
index a3dba99..e1250c5 100644
--- a/toolkit/source/awt/vclxwindow1.cxx
+++ b/toolkit/source/awt/vclxwindow1.cxx
@@ -55,10 +55,9 @@
     Window *pWindow = GetWindow();
     if ( pWindow->GetType() != WINDOW_WORKWINDOW )
     {
-        ::com::sun::star::uno::Exception *pException =
-            new ::com::sun::star::uno::RuntimeException;
-        pException->Message = ::rtl::OUString("not a work window");
-        throw pException;
+        com::sun::star::uno::Exception aException;
+        aException.Message = ::rtl::OUString("not a work window");
+        throw aException;
     }
 
     // use sal_Int64 here to accomodate all int types
@@ -86,10 +85,9 @@
     }
     if( bThrow )
     {
-        ::com::sun::star::uno::Exception *pException =
-            new ::com::sun::star::uno::RuntimeException;
-        pException->Message = ::rtl::OUString("incorrect window handle type");
-        throw pException;
+        com::sun::star::uno::Exception aException;
+        aException.Message = ::rtl::OUString("incorrect window handle type");
+        throw aException;
     }
     // create system parent data
     SystemParentData aSysParentData;

-- 
To view, visit https://gerrit.libreoffice.org/3420
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I22b7d3d642e7ee0488d6b726a331d328065bbee7
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: libreoffice-3-6
Gerrit-Owner: Stephan Bergmann <sbergman@redhat.com>


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.