Skip to content

Commit

Permalink
Merge pull request micro-manager#476 from tlambert03/check-init-befor…
Browse files Browse the repository at this point in the history
…e-get-installed

add safeguard to getInstalledDevices to check for device initialization
  • Loading branch information
marktsuchida authored Jul 5, 2024
2 parents 51b04ce + 2d2b7c3 commit 3f240a0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions MMCore/MMCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7526,11 +7526,19 @@ MM::DeviceDetectionStatus CMMCore::detectDevice(const char* label)
* device. Doing otherwise results in undefined behavior. This function was
* intended for use during initial configuration, not routine loading of
* devices. These restrictions may be relaxed in the future if possible.
*
* Throws an exception if the hub device is not initialized.
*
* @param hubDeviceLabel the label for the device of type Hub
*/
std::vector<std::string> CMMCore::getInstalledDevices(const char* hubDeviceLabel) throw (CMMError)
{
if (isFeatureEnabled("StrictInitializationChecks")) {
if (getDeviceInitializationState(hubDeviceLabel) == DeviceInitializationState::Uninitialized) {
throw CMMError("Device " + ToQuotedString(hubDeviceLabel) + " is not yet initialized.");
}
}

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

Expand Down

0 comments on commit 3f240a0

Please sign in to comment.