Fixed bug with TargetController attempting to release hardware that it no longer has access to.

Under some circumstances, this bug was leaving the debug tool in a bad state.
This commit is contained in:
Nav
2022-03-17 00:00:40 +00:00
parent fbffbcdf77
commit 2cb5b13247
2 changed files with 6 additions and 13 deletions

View File

@@ -333,8 +333,12 @@ namespace Bloom
}
void TargetController::releaseHardware() {
auto target = this->getTarget();
auto debugTool = this->getDebugTool();
/*
* Transferring ownership of this->debugTool and this->target to this function block means if an exception is
* thrown, the objects will still be destroyed.
*/
auto debugTool = std::move(this->debugTool);
auto target = std::move(this->target);
if (debugTool != nullptr && debugTool->isInitialised()) {
if (target != nullptr) {
@@ -349,9 +353,6 @@ namespace Bloom
Logger::info("Closing debug tool");
debugTool->close();
}
this->debugTool.reset();
this->target.reset();
}
void TargetController::loadRegisterDescriptors() {

View File

@@ -199,14 +199,6 @@ namespace Bloom
return mapping;
}
Targets::Target* getTarget() {
return this->target.get();
}
DebugTool* getDebugTool() {
return this->debugTool.get();
}
/**
* Updates the state of the TargetController and emits a state changed event.
*