summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-09-10 11:15:06 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-09-12 08:58:20 +0200
commit1b88de0a07180661c4d5d6706247d546d06bc983 (patch)
tree2eb7d5e0f96c760553b1945314b901ef1d915bc9 /sd
parentd6de1390b848412196cebef86f75c1b36289fc92 (diff)
loplugin:useuniqueptr in sd::BluetoothServer
Change-Id: I42c11e4a178a92024de8f764af582f60c36302d5 Reviewed-on: https://gerrit.libreoffice.org/60342 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd')
-rw-r--r--sd/source/ui/remotecontrol/BluetoothServer.cxx28
1 files changed, 12 insertions, 16 deletions
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;