Corrected string->int conversion bug in TargetPinDescriptor.

The `numericPosition` member should really be removed. Will revisit later.
This commit is contained in:
Nav
2024-10-27 00:28:41 +01:00
parent 4f166cc7d7
commit f0b7f3193c
4 changed files with 14 additions and 2 deletions

View File

@@ -9,7 +9,11 @@ namespace Targets
const std::optional<std::string>& padKey
)
: position(position)
, numericPosition(Services::StringService::toUint16(this->position, 10))
, numericPosition(
Services::StringService::isNumeric(this->position)
? Services::StringService::toUint16(this->position, 10)
: 0
)
, padKey(padKey)
{}
}

View File

@@ -10,7 +10,7 @@ namespace Targets
{
public:
std::string position;
std::uint16_t numericPosition;
std::uint16_t numericPosition; // TODO: Consider removing this bodge. Review after v1.1.0
std::optional<std::string> padKey;
TargetPinDescriptor(