Skip to content

FreenectDriver Shouldn't Remove Device from devices() #593

@TroikaTronix

Description

@TroikaTronix

When closing an OpenNI Device using openni::Device::close(), the function deviceClose() in DeviceDriver.cp removes the device from the devices list. If you attempt to reopen the device using openni::Device::open() without reiniting OpenNI entirely, the call will erroneously fail because it says the device doesn't exist.

For situations where OpenNI is not a singleton, this is problematic becasue if you cannot reopen the device without calling the global function openni::OpenNI::shutdown() followed by openni::OpenNI::initialize() to rebuild the list of available devices.

Starting at line 307 of DeviceDriver.cpp is the following code

devices.erase(iter);
deleteDevice(id);

Since the actual device is deinstantiated by when deleteDevice(id) is called, you should simply set the the OpenNI driver pointer to NULL, and then go ahead and delete the device

iter->second = NULL;
deleteDevice(id);

This ensures that the entry for the device remains in the table and it will be found by a subsequent call to openni::Device::open()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions