Delete Leap and RealSense devices on shutdown

Leaving them running prevents a clean shutdown on Windows when running
Interface.exe from a command line: the interface.exe process stays alive
preventing Interface from being run again from the command line without
manually terminating the running process.
This commit is contained in:
David Rowe 2015-05-07 18:28:49 -07:00
parent bb77ba95d0
commit e20df0e2bf
7 changed files with 24 additions and 0 deletions

View file

@ -690,6 +690,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
}

View file

@ -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++) {

View file

@ -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();

View file

@ -50,6 +50,11 @@ void Leapmotion::init() {
}
}
// static
void Leapmotion::destroy() {
DeviceTracker::destroyDevice(NAME);
}
// static
Leapmotion* Leapmotion::getInstance() {
DeviceTracker* device = DeviceTracker::getDevice(NAME);

View file

@ -26,6 +26,7 @@ public:
static const Name NAME;
static void init();
static void destroy();
/// Leapmotion MotionTracker factory
static Leapmotion* getInstance();

View file

@ -54,6 +54,11 @@ void RealSense::init() {
}
}
// static
void RealSense::destroy() {
DeviceTracker::destroyDevice(NAME);
}
// static
RealSense* RealSense::getInstance() {
DeviceTracker* device = DeviceTracker::getDevice(NAME);

View file

@ -32,6 +32,7 @@ public:
static const Name NAME;
static void init();
static void destroy();
/// RealSense MotionTracker factory
static RealSense* getInstance();