X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2FFNetBt_BluetoothHdpSystemAdapter.cpp;h=287a9fe4dbe94af4545d43d4917e48993a79b2fd;hb=d2ffcdd0f633b45639766e9e0aa5c6074570d981;hp=8045ae1b8f36a2c1099ce274eb264f12a7e0b5aa;hpb=1c09b080c21e4505770ed2133bbb674ff2f00eb9;p=platform%2Fframework%2Fnative%2Fbluetooth.git diff --git a/src/FNetBt_BluetoothHdpSystemAdapter.cpp b/src/FNetBt_BluetoothHdpSystemAdapter.cpp index 8045ae1..287a9fe 100755 --- a/src/FNetBt_BluetoothHdpSystemAdapter.cpp +++ b/src/FNetBt_BluetoothHdpSystemAdapter.cpp @@ -104,24 +104,32 @@ _BluetoothHdpSystemAdapter::_BluetoothHdpSystemAdapter(void) _BluetoothHdpSystemAdapter::~_BluetoothHdpSystemAdapter(void) { - // unregister the callback methods from the underlying layer - int err = bt_hdp_unset_connection_state_changed_cb(); - SysLog(NID_NET_BT, "[0x%x] error in unregistering the connection state change callback method", err); - - err = bt_hdp_unset_data_received_cb(); - SysLog(NID_NET_BT, "[0x%x] error in unregistering the data received state change callback method", err); } void _BluetoothHdpSystemAdapter::InitSingleton(void) { bool r = false; - static _BluetoothHdpSystemAdapter inst; + std::unique_ptr<_BluetoothHdpSystemAdapter> pInst; - r = inst.Construct(); + pInst.reset(new (std::nothrow) _BluetoothHdpSystemAdapter()); + r = pInst->Construct(); SysTryReturnVoidResult(NID_NET_BT, r == true, E_SYSTEM, "[E_SYSTEM] Propagating."); - __pInstance = &inst; + __pInstance = pInst.release(); + + std::atexit(DeinitializeSingleton); +} + +void +_BluetoothHdpSystemAdapter::DeinitializeSingleton(void) +{ + // unregister the callback methods from the underlying layer + int err = bt_hdp_unset_connection_state_changed_cb(); + SysLog(NID_NET_BT, "[0x%x] error in unregistering the connection state change callback method", err); + + err = bt_hdp_unset_data_received_cb(); + SysLog(NID_NET_BT, "[0x%x] error in unregistering the data received state change callback method", err); } _BluetoothHdpSystemAdapter*