diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 8d660848f2..e65787dbc8 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -692,6 +692,9 @@ Application::~Application() { nodeThread->quit(); nodeThread->wait(); + Leapmotion::destroy(); + RealSense::destroy(); + qInstallMessageHandler(NULL); // NOTE: Do this as late as possible so we continue to get our log messages } diff --git a/interface/src/devices/DeviceTracker.cpp b/interface/src/devices/DeviceTracker.cpp index 265a77b362..aa0e68ff47 100644 --- a/interface/src/devices/DeviceTracker.cpp +++ b/interface/src/devices/DeviceTracker.cpp @@ -66,6 +66,13 @@ DeviceTracker::ID DeviceTracker::registerDevice(const Name& name, DeviceTracker* return deviceID; } +void DeviceTracker::destroyDevice(const Name& name) { + DeviceTracker::ID deviceID = getDeviceID(name); + if (deviceID != INVALID_DEVICE) { + delete Singleton::get()->_devicesVector[getDeviceID(name)]; + } +} + void DeviceTracker::updateAll() { //TODO C++11 for (auto deviceIt = Singleton::get()->_devicesVector.begin(); deviceIt != Singleton::get()->_devicesVector.end(); deviceIt++) { for (Vector::iterator deviceIt = Singleton::get()->_devicesVector.begin(); deviceIt != Singleton::get()->_devicesVector.end(); deviceIt++) { diff --git a/interface/src/devices/DeviceTracker.h b/interface/src/devices/DeviceTracker.h index 2e0f69b371..b28e22b06d 100644 --- a/interface/src/devices/DeviceTracker.h +++ b/interface/src/devices/DeviceTracker.h @@ -79,6 +79,8 @@ public: /// INVALID_DEVICE_NAME if the name is already taken static ID registerDevice(const Name& name, DeviceTracker* tracker); + static void destroyDevice(const Name& name); + // DeviceTracker interface virtual void update(); diff --git a/interface/src/devices/Leapmotion.cpp b/interface/src/devices/Leapmotion.cpp index 04cd51a484..cb99cf324d 100644 --- a/interface/src/devices/Leapmotion.cpp +++ b/interface/src/devices/Leapmotion.cpp @@ -50,6 +50,11 @@ void Leapmotion::init() { } } +// static +void Leapmotion::destroy() { + DeviceTracker::destroyDevice(NAME); +} + // static Leapmotion* Leapmotion::getInstance() { DeviceTracker* device = DeviceTracker::getDevice(NAME); diff --git a/interface/src/devices/Leapmotion.h b/interface/src/devices/Leapmotion.h index a0c75da38f..266b9beb87 100644 --- a/interface/src/devices/Leapmotion.h +++ b/interface/src/devices/Leapmotion.h @@ -26,6 +26,7 @@ public: static const Name NAME; static void init(); + static void destroy(); /// Leapmotion MotionTracker factory static Leapmotion* getInstance(); diff --git a/interface/src/devices/RealSense.cpp b/interface/src/devices/RealSense.cpp index 8e9cd85451..d9b1486f09 100644 --- a/interface/src/devices/RealSense.cpp +++ b/interface/src/devices/RealSense.cpp @@ -54,6 +54,11 @@ void RealSense::init() { } } +// static +void RealSense::destroy() { + DeviceTracker::destroyDevice(NAME); +} + // static RealSense* RealSense::getInstance() { DeviceTracker* device = DeviceTracker::getDevice(NAME); diff --git a/interface/src/devices/RealSense.h b/interface/src/devices/RealSense.h index 20111365d0..c958ab1e53 100644 --- a/interface/src/devices/RealSense.h +++ b/interface/src/devices/RealSense.h @@ -32,6 +32,7 @@ public: static const Name NAME; static void init(); + static void destroy(); /// RealSense MotionTracker factory static RealSense* getInstance();