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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Aug 24 06:55:19 UTC 2018


 sd/source/ui/remotecontrol/BluetoothServer.cxx |    9 +++++----
 sd/source/ui/remotecontrol/Communicator.cxx    |    4 ++--
 sd/source/ui/remotecontrol/Communicator.hxx    |    2 +-
 sd/source/ui/remotecontrol/Server.cxx          |    2 +-
 4 files changed, 9 insertions(+), 8 deletions(-)

New commits:
commit 68b9553d44769947dfe3899b396d9236d4406ddf
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Aug 23 10:49:31 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Aug 24 08:54:52 2018 +0200

    loplugin:useuniqueptr in sd::Communicator
    
    Change-Id: Iedfe9aa982b64e8ba7d07c74d60cabd101538357
    Reviewed-on: https://gerrit.libreoffice.org/59491
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sd/source/ui/remotecontrol/BluetoothServer.cxx b/sd/source/ui/remotecontrol/BluetoothServer.cxx
index 0a13f5847ecb..f1f5e06664da 100644
--- a/sd/source/ui/remotecontrol/BluetoothServer.cxx
+++ b/sd/source/ui/remotecontrol/BluetoothServer.cxx
@@ -51,6 +51,7 @@
 #endif
 
 #include "Communicator.hxx"
+#include <o3tl/make_unique.hxx>
 
 using namespace sd;
 
@@ -557,7 +558,7 @@ void incomingCallback( void *userRefCon,
     IOBluetoothRFCOMMChannel* channel = [IOBluetoothRFCOMMChannel withRFCOMMChannelRef:reinterpret_cast<IOBluetoothRFCOMMChannelRef>(objectRef)];
 
     OSXBluetoothWrapper* socket = new OSXBluetoothWrapper( channel);
-    Communicator* pCommunicator = new Communicator( socket );
+    Communicator* pCommunicator = new Communicator( std::unique_ptr<IBluetoothSocket>(socket) );
     pServer->addCommunicator( pCommunicator );
 
     ChannelDelegate* delegate = [[ChannelDelegate alloc] initWithCommunicatorAndSocket: pCommunicator socket: socket];
@@ -920,7 +921,7 @@ DBusHandlerResult ProfileMessageFunction
                     (void)fcntl(nDescriptor, F_SETFL, fcntl(nDescriptor, F_GETFL) & ~O_NONBLOCK);
 
                     SAL_INFO( "sdremote.bluetooth", "connection accepted " << nDescriptor);
-                    Communicator* pCommunicator = new Communicator( new BufferedStreamSocket( nDescriptor ) );
+                    Communicator* pCommunicator = new Communicator( o3tl::make_unique<BufferedStreamSocket>( nDescriptor ) );
                     pCommunicators->push_back( pCommunicator );
                     pCommunicator->launch();
                 }
@@ -1289,7 +1290,7 @@ void SAL_CALL BluetoothServer::run()
                 SAL_WARN( "sdremote.bluetooth", "accept failed with errno " << errno );
             } else {
                 SAL_INFO( "sdremote.bluetooth", "connection accepted " << nClient );
-                Communicator* pCommunicator = new Communicator( new BufferedStreamSocket( nClient ) );
+                Communicator* pCommunicator = new Communicator( o3tl::make_unique<BufferedStreamSocket>( nClient ) );
                 mpCommunicators->push_back( pCommunicator );
                 pCommunicator->launch();
             }
@@ -1388,7 +1389,7 @@ void SAL_CALL BluetoothServer::run()
             WSACleanup();
             return;
         } else {
-            Communicator* pCommunicator = new Communicator( new BufferedStreamSocket( socket) );
+            Communicator* pCommunicator = new Communicator( o3tl::make_unique<BufferedStreamSocket>( socket) );
             mpCommunicators->push_back( pCommunicator );
             pCommunicator->launch();
         }
diff --git a/sd/source/ui/remotecontrol/Communicator.cxx b/sd/source/ui/remotecontrol/Communicator.cxx
index b5d595c221d2..f1431d26991a 100644
--- a/sd/source/ui/remotecontrol/Communicator.cxx
+++ b/sd/source/ui/remotecontrol/Communicator.cxx
@@ -29,9 +29,9 @@ using namespace std;
 using namespace com::sun::star;
 using namespace osl;
 
-Communicator::Communicator( IBluetoothSocket *pSocket ):
+Communicator::Communicator( std::unique_ptr<IBluetoothSocket> pSocket ):
     Thread( "CommunicatorThread" ),
-    mpSocket( pSocket ),
+    mpSocket( std::move(pSocket) ),
     pTransmitter( nullptr ),
     mListener( nullptr )
 {
diff --git a/sd/source/ui/remotecontrol/Communicator.hxx b/sd/source/ui/remotecontrol/Communicator.hxx
index 893dab2a1367..f32ae480808b 100644
--- a/sd/source/ui/remotecontrol/Communicator.hxx
+++ b/sd/source/ui/remotecontrol/Communicator.hxx
@@ -39,7 +39,7 @@ namespace sd
     class Communicator : public salhelper::Thread
     {
         public:
-            explicit Communicator( IBluetoothSocket *pSocket );
+            explicit Communicator( std::unique_ptr<IBluetoothSocket> pSocket );
             virtual ~Communicator() override;
 
             void presentationStarted( const css::uno::Reference<
diff --git a/sd/source/ui/remotecontrol/Server.cxx b/sd/source/ui/remotecontrol/Server.cxx
index 0fbedb325146..2027834c0159 100644
--- a/sd/source/ui/remotecontrol/Server.cxx
+++ b/sd/source/ui/remotecontrol/Server.cxx
@@ -313,7 +313,7 @@ bool RemoteServer::connectClient( const std::shared_ptr< ClientInfo >& pClient,
             aChanges->commit();
         }
 
-        Communicator* pCommunicator = new Communicator( apClient->mpStreamSocket );
+        Communicator* pCommunicator = new Communicator( std::unique_ptr<IBluetoothSocket>(apClient->mpStreamSocket) );
         MutexGuard aGuard( sDataMutex );
 
         sCommunicators.push_back( pCommunicator );


More information about the Libreoffice-commits mailing list