io/source/stm/opump.cxx  |    4 ++--
 io/test/stm/datatest.cxx |    9 +++------
 io/test/stm/marktest.cxx |    6 ++----
 io/test/stm/pipetest.cxx |    4 +---
 4 files changed, 8 insertions(+), 15 deletions(-)

New commits:
commit 87276a497d9aa8a3f8ac0bfceb75d64938945f9a
Author:     Mike Kaganski <[email protected]>
AuthorDate: Sun Apr 23 20:14:07 2023 +0300
Commit:     Mike Kaganski <[email protected]>
CommitDate: Sat May 27 18:08:00 2023 +0200

    Use getXWeak in io
    
    Change-Id: If2b40ecdca67c6d82ff1a87443cb8533401e9ae8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150856
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <[email protected]>

diff --git a/io/source/stm/opump.cxx b/io/source/stm/opump.cxx
index fc751b677f95..df3e6132319d 100644
--- a/io/source/stm/opump.cxx
+++ b/io/source/stm/opump.cxx
@@ -263,14 +263,14 @@ void Pump::run()
 
             if( ! rInput.is() )
             {
-                throw NotConnectedException( "no input stream set", 
static_cast<OWeakObject*>(this) );
+                throw NotConnectedException( "no input stream set", getXWeak() 
);
             }
             Sequence< sal_Int8 > aData;
             while( rInput->readSomeBytes( aData, 65536 ) )
             {
                 if( ! rOutput.is() )
                 {
-                    throw NotConnectedException( "no output stream set", 
static_cast<OWeakObject*>(this) );
+                    throw NotConnectedException( "no output stream set", 
getXWeak() );
                 }
                 rOutput->writeBytes( aData );
                 osl_yieldThread();
diff --git a/io/test/stm/datatest.cxx b/io/test/stm/datatest.cxx
index a085bf6d7d5b..ef31f099d496 100644
--- a/io/test/stm/datatest.cxx
+++ b/io/test/stm/datatest.cxx
@@ -326,8 +326,7 @@ void ODataStreamTest::testSimple(   const Reference < 
XDataInputStream > &rInput
 **/
 Reference < XInterface > SAL_CALL ODataStreamTest_CreateInstance( const 
Reference < XMultiServiceFactory > & rSMgr ) throw(Exception)
 {
-    ODataStreamTest *p = new ODataStreamTest( rSMgr );
-    return Reference < XInterface > ( (static_cast< OWeakObject *  >(p)) );
+    return getXWeak(new ODataStreamTest( rSMgr ));
 }
 
 Sequence<OUString> ODataStreamTest_getSupportedServiceNames( int i) throw ()
@@ -596,8 +595,7 @@ Reference < XInterface > SAL_CALL 
OMyPersistObject_CreateInstance(
     const Reference < XMultiServiceFactory > & rSMgr )
     throw(Exception)
 {
-    MyPersistObject *p = new MyPersistObject( );
-    return Reference < XInterface > ( (static_cast< OWeakObject *  >(p)) );
+    return getXWeak(new MyPersistObject( ));
 }
 
 Sequence<OUString> OMyPersistObject_getSupportedServiceNames( ) throw ()
@@ -1040,8 +1038,7 @@ void OObjectStreamTest::testObject(     const Reference<  
XObjectOutputStream >
 
 Reference < XInterface > SAL_CALL OObjectStreamTest_CreateInstance( const 
Reference < XMultiServiceFactory > & rSMgr ) throw(Exception)
 {
-    OObjectStreamTest *p = new OObjectStreamTest( rSMgr );
-    return Reference < XInterface > ( (static_cast< OWeakObject *  >(p)) );
+    return getXWeak(new OObjectStreamTest( rSMgr ));
 }
 
 Sequence<OUString> OObjectStreamTest_getSupportedServiceNames( int i) throw ()
diff --git a/io/test/stm/marktest.cxx b/io/test/stm/marktest.cxx
index fbfc2008214f..0dd01a7f7747 100644
--- a/io/test/stm/marktest.cxx
+++ b/io/test/stm/marktest.cxx
@@ -360,8 +360,7 @@ void OMarkableOutputStreamTest::testSimple(     const 
Reference< XOutputStream >
 **/
 Reference < XInterface > SAL_CALL OMarkableOutputStreamTest_CreateInstance( 
const Reference< XMultiServiceFactory > & rSMgr ) throw(Exception)
 {
-    OMarkableOutputStreamTest *p = new OMarkableOutputStreamTest( rSMgr );
-    return Reference < XInterface > ( (static_cast< OWeakObject *  >(p)) );
+    return getXWeak(new OMarkableOutputStreamTest( rSMgr ));
 }
 
 
@@ -619,8 +618,7 @@ void OMarkableInputStreamTest::testSimple(      const 
Reference< XOutputStream >
 **/
 Reference < XInterface > SAL_CALL OMarkableInputStreamTest_CreateInstance( 
const Reference< XMultiServiceFactory > & rSMgr ) throw(Exception)
 {
-    OMarkableInputStreamTest *p = new OMarkableInputStreamTest( rSMgr );
-    return Reference < XInterface > ( (static_cast< OWeakObject *  >(p)) );
+    return getXWeak(new OMarkableInputStreamTest( rSMgr ));
 }
 
 
diff --git a/io/test/stm/pipetest.cxx b/io/test/stm/pipetest.cxx
index 46637f3f245a..da5c5f20ba49 100644
--- a/io/test/stm/pipetest.cxx
+++ b/io/test/stm/pipetest.cxx
@@ -392,9 +392,7 @@ void OPipeTest::testMultithreading( const Reference < 
XInterface > &r )
 **/
 Reference < XInterface > SAL_CALL OPipeTest_CreateInstance( const Reference< 
XMultiServiceFactory>  & rSMgr ) throw (Exception)
 {
-    OPipeTest *p = new OPipeTest( rSMgr );
-    Reference< XInterface > x ( (static_cast< OWeakObject *  >(p)) );
-    return x;
+    return getXWeak(new OPipeTest( rSMgr ));
 }
 
 

Reply via email to