diff --git a/senseApis/xcbWindow/xcbWindow.cpp b/senseApis/xcbWindow/xcbWindow.cpp index be975e3..70521c2 100644 --- a/senseApis/xcbWindow/xcbWindow.cpp +++ b/senseApis/xcbWindow/xcbWindow.cpp @@ -312,15 +312,17 @@ static int xcbWindow_detachDeviceReq(const smo::device::SenseDeviceSpec& spec) } ); - if (it != g_attachedWindows.end()) + if (it == g_attachedWindows.end()) { - g_attachedWindows.erase(it); - std::cout << __func__ << ": Detached X11 window device\n"; - return 0; + std::cerr << __func__ << ": Device not found for detachment:\n" + << spec.stringify() << "\n"; + return -1; } - std::cerr << __func__ << ": Device not found for detachment\n"; - return -1; + g_attachedWindows.erase(it); + std::cout << __func__ << ": Detached X11 window device:\n" + << spec.stringify() << "\n"; + return 0; } // SenseApi descriptor