Kaydet (Commit) 638be04c authored tarafından Noel Grandin's avatar Noel Grandin

use unique_ptr in sd::BluetoothServer::Impl

Change-Id: I54bd8fbac488182d2017e90b7afced2659f01728
Reviewed-on: https://gerrit.libreoffice.org/65955
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 7a26512f
...@@ -90,14 +90,13 @@ struct sd::BluetoothServer::Impl { ...@@ -90,14 +90,13 @@ struct sd::BluetoothServer::Impl {
// the glib mainloop running in the thread // the glib mainloop running in the thread
GMainContext *mpContext; GMainContext *mpContext;
DBusConnection *mpConnection; DBusConnection *mpConnection;
DBusObject *mpService; std::unique_ptr<DBusObject> mpService;
enum class BluezVersion { BLUEZ4, BLUEZ5, UNKNOWN }; enum class BluezVersion { BLUEZ4, BLUEZ5, UNKNOWN };
BluezVersion maBluezVersion; BluezVersion maBluezVersion;
Impl() Impl()
: mpContext( g_main_context_new() ) : mpContext( g_main_context_new() )
, mpConnection( nullptr ) , mpConnection( nullptr )
, mpService( nullptr )
, maBluezVersion( BluezVersion::UNKNOWN ) , maBluezVersion( BluezVersion::UNKNOWN )
{ } { }
...@@ -853,17 +852,15 @@ setDiscoverable( DBusConnection *pConnection, DBusObject *pAdapter, bool bDiscov ...@@ -853,17 +852,15 @@ setDiscoverable( DBusConnection *pConnection, DBusObject *pAdapter, bool bDiscov
} }
} }
static DBusObject * static std::unique_ptr<DBusObject>
registerWithDefaultAdapter( DBusConnection *pConnection ) registerWithDefaultAdapter( DBusConnection *pConnection )
{ {
DBusObject *pService; std::unique_ptr<DBusObject> pService(bluez4GetDefaultService( pConnection ));
pService = bluez4GetDefaultService( pConnection );
if( pService ) if( pService )
{ {
if( !bluez4RegisterServiceRecord( pConnection, pService, if( !bluez4RegisterServiceRecord( pConnection, pService.get(),
bluetooth_service_record ) ) bluetooth_service_record ) )
{ {
delete pService;
return nullptr; return nullptr;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment