sd/source/ui/remotecontrol/BluetoothServer.cxx | 28 ++++++++++--------------- 1 file changed, 12 insertions(+), 16 deletions(-)
New commits: commit 1b88de0a07180661c4d5d6706247d546d06bc983 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Mon Sep 10 11:15:06 2018 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Sep 12 08:58:20 2018 +0200 loplugin:useuniqueptr in sd::BluetoothServer Change-Id: I42c11e4a178a92024de8f764af582f60c36302d5 Reviewed-on: https://gerrit.libreoffice.org/60342 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sd/source/ui/remotecontrol/BluetoothServer.cxx b/sd/source/ui/remotecontrol/BluetoothServer.cxx index f1f5e06664da..75896752ca1e 100644 --- a/sd/source/ui/remotecontrol/BluetoothServer.cxx +++ b/sd/source/ui/remotecontrol/BluetoothServer.cxx @@ -71,9 +71,9 @@ struct DBusObject { return dbus_message_new_method_call( maBusName.getStr(), maPath.getStr(), maInterface.getStr(), pName ); } - DBusObject *cloneForInterface( const char *pInterface ) + std::unique_ptr<DBusObject> cloneForInterface( const char *pInterface ) { - DBusObject *pObject = new DBusObject(); + std::unique_ptr<DBusObject> pObject(new DBusObject()); pObject->maBusName = maBusName; pObject->maPath = maPath; @@ -83,7 +83,7 @@ struct DBusObject { } }; -static DBusObject* getBluez5Adapter(DBusConnection *pConnection); +static std::unique_ptr<DBusObject> getBluez5Adapter(DBusConnection *pConnection); struct sd::BluetoothServer::Impl { // the glib mainloop running in the thread @@ -100,12 +100,11 @@ struct sd::BluetoothServer::Impl { , maBluezVersion( UNKNOWN ) { } - DBusObject *getAdapter() + std::unique_ptr<DBusObject> getAdapter() { if (mpService) { - DBusObject* pAdapter = mpService->cloneForInterface( "org.bluez.Adapter" ); - return pAdapter; + return mpService->cloneForInterface( "org.bluez.Adapter" ); } else if (spServer->mpImpl->maBluezVersion == BLUEZ5) { @@ -199,7 +198,7 @@ isBluez5Available(DBusConnection *pConnection) return true; } -static DBusObject* +static std::unique_ptr<DBusObject> getBluez5Adapter(DBusConnection *pConnection) { DBusMessage *pMsg; @@ -257,7 +256,7 @@ getBluez5Adapter(DBusConnection *pConnection) dbus_message_unref(pMsg); if (pPath) { - return new DBusObject( "org.bluez", pPath, pInterfaceType ); + return o3tl::make_unique<DBusObject>( "org.bluez", pPath, pInterfaceType ); } assert(false); // We should already have pPath provided for us. } @@ -1119,17 +1118,15 @@ void BluetoothServer::doEnsureDiscoverable() return; // Find out if we are discoverable already ... - DBusObject *pAdapter = spServer->mpImpl->getAdapter(); + std::unique_ptr<DBusObject> pAdapter = spServer->mpImpl->getAdapter(); if( !pAdapter ) return; - bool bDiscoverable = getDiscoverable(spServer->mpImpl->mpConnection, pAdapter ); + bool bDiscoverable = getDiscoverable(spServer->mpImpl->mpConnection, pAdapter.get() ); spServer->meWasDiscoverable = bDiscoverable ? DISCOVERABLE : NOT_DISCOVERABLE; if( !bDiscoverable ) - setDiscoverable( spServer->mpImpl->mpConnection, pAdapter, true ); - - delete pAdapter; + setDiscoverable( spServer->mpImpl->mpConnection, pAdapter.get(), true ); #endif } @@ -1138,11 +1135,10 @@ void BluetoothServer::doRestoreDiscoverable() if( spServer->meWasDiscoverable == NOT_DISCOVERABLE ) { #ifdef LINUX_BLUETOOTH - DBusObject *pAdapter = spServer->mpImpl->getAdapter(); + std::unique_ptr<DBusObject> pAdapter = spServer->mpImpl->getAdapter(); if( !pAdapter ) return; - setDiscoverable( spServer->mpImpl->mpConnection, pAdapter, false ); - delete pAdapter; + setDiscoverable( spServer->mpImpl->mpConnection, pAdapter.get(), false ); #endif } spServer->meWasDiscoverable = UNKNOWN; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits