Skip to content

c++ api - remove get_removed_devices method from event_information class - #2823

Merged
dorodnic merged 1 commit into
realsenseai:developmentfrom
matkatz:remove_get_removed_devices_api
Dec 4, 2018
Merged

c++ api - remove get_removed_devices method from event_information class#2823
dorodnic merged 1 commit into
realsenseai:developmentfrom
matkatz:remove_get_removed_devices_api

Conversation

@matkatz

@matkatz matkatz commented Dec 2, 2018

Copy link
Copy Markdown
Contributor

Jira issue:
DS5DSO-10869 - OnDeviceChange provide a removed list which cause crash on enumeration

The current API allows the user to iterate the removed devices list as following:

    ctx.set_devices_changed_callback([&](rs2::event_information& info)
    {
        for (auto& d : info.get_removed_devices()) { }
    });

This code will always throw exception since iterating the list tries to create the devices in the list.
And since the device is not available, exception is thrown.

The correct way to check if a device was removed is:

    ctx.set_devices_changed_callback([&](rs2::event_information& info)
    {
        if (info.was_removed(my_device))
            handle_device_removale();
    });

@dorodnic

dorodnic commented Dec 2, 2018

Copy link
Copy Markdown
Contributor

Please add more information on the reason for this change

@dorodnic
dorodnic merged commit 218a6fa into realsenseai:development Dec 4, 2018
@matkatz
matkatz deleted the remove_get_removed_devices_api branch December 23, 2018 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants