summaryrefslogtreecommitdiff
path: root/src/components/transport_manager/src/usb/usb_connection_factory.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/transport_manager/src/usb/usb_connection_factory.cc')
-rw-r--r--src/components/transport_manager/src/usb/usb_connection_factory.cc20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/components/transport_manager/src/usb/usb_connection_factory.cc b/src/components/transport_manager/src/usb/usb_connection_factory.cc
index 28992d8f40..1136dfad21 100644
--- a/src/components/transport_manager/src/usb/usb_connection_factory.cc
+++ b/src/components/transport_manager/src/usb/usb_connection_factory.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Ford Motor Company
+ * Copyright (c) 2017, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -34,6 +34,7 @@
#include "transport_manager/usb/usb_device.h"
#include "transport_manager/transport_adapter/transport_adapter_impl.h"
#include "utils/logger.h"
+#include "utils/make_shared.h"
#if defined(__QNXNTO__)
#include "transport_manager/usb/qnx/usb_connection.h"
@@ -73,15 +74,14 @@ TransportAdapter::Error UsbConnectionFactory::CreateConnection(
}
UsbDevice* usb_device = static_cast<UsbDevice*>(device.get());
- UsbConnection* usb_connection = new UsbConnection(device_uid,
- app_handle,
- controller_,
- usb_handler_,
- usb_device->usb_device());
-
- controller_->ConnectionCreated(usb_connection, device_uid, app_handle);
-
- if (usb_connection->Init()) {
+ utils::SharedPtr<UsbConnection> connection =
+ utils::MakeShared<UsbConnection>(device_uid,
+ app_handle,
+ controller_,
+ usb_handler_,
+ usb_device->usb_device());
+ controller_->ConnectionCreated(connection, device_uid, app_handle);
+ if (connection->Init()) {
LOG4CXX_INFO(logger_, "USB connection initialised");
LOG4CXX_TRACE(logger_,
"exit with TransportAdapter::OK. Condition: USB connection "