Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add safeguard to getInstalledDevices to check for device initialization #476

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions MMCore/MMCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7529,8 +7529,18 @@ MM::DeviceDetectionStatus CMMCore::detectDevice(const char* label)
*
* @param hubDeviceLabel the label for the device of type Hub
*/
std::vector<std::string> CMMCore::getInstalledDevices(const char* hubDeviceLabel) throw (CMMError)
{
std::vector<std::string> CMMCore::getInstalledDevices(const char* hubDeviceLabel, bool force) throw (CMMError)
{
if (isFeatureEnabled("StrictInitializationChecks") && !force) {
DeviceInitializationState initState = getDeviceInitializationState(hubDeviceLabel);
if (initState == DeviceInitializationState::Uninitialized) {
throw CMMError("Device " + ToQuotedString(hubDeviceLabel) +
" is not yet initialized, and you may only call this method once. " +
"This may not be what you want to do. "
"Use force=true to call it anyway.");
tlambert03 marked this conversation as resolved.
Show resolved Hide resolved
}
}

std::shared_ptr<HubInstance> pHub =
deviceManager_->GetDeviceOfType<HubInstance>(hubDeviceLabel);

Expand Down
2 changes: 1 addition & 1 deletion MMCore/MMCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ class CMMCore
void setParentLabel(const char* deviceLabel,
const char* parentHubLabel) throw (CMMError);

std::vector<std::string> getInstalledDevices(const char* hubLabel) throw (CMMError);
std::vector<std::string> getInstalledDevices(const char* hubLabel, bool force = false) throw (CMMError);
tlambert03 marked this conversation as resolved.
Show resolved Hide resolved
std::string getInstalledDeviceDescription(const char* hubLabel,
const char* peripheralLabel) throw (CMMError);
std::vector<std::string> getLoadedPeripheralDevices(const char* hubLabel) throw (CMMError);
Expand Down
Loading