diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperChoiceParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperChoiceParameter.h index da4d4537b7a30d7bcc9e227416878d15aa2e3dad..b376323214a31e02f6846b80d2aed4c7b126e6e3 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperChoiceParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperChoiceParameter.h @@ -90,13 +90,14 @@ public: bool HasValue() const ITK_OVERRIDE { - // a choice parameter always has a value - return true; + return !m_ChoiceList.empty(); } void ClearValue() ITK_OVERRIDE { - // nothing to do : a choice parameter always has a value + // Same as constructor init value + // Note that this may be invalid if HasValue() == false + m_CurrentChoice = 0; } protected: diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index c2d772d151c62a42a8ee3ba9a7e09a496518c66d..16f2a28637401ce72a634f4e4074a9f0bdf3bee9 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -1015,19 +1015,26 @@ std::string Application::GetParameterString(std::string parameter) Parameter* param = GetParameterByKey(parameter); if (dynamic_cast<ChoiceParameter*>(param)) - { + { ChoiceParameter* paramDown = dynamic_cast<ChoiceParameter*>(param); - std::string choiceKey = paramDown->GetChoiceKey( paramDown->GetValue() ); - size_t lastPointPos = choiceKey.find_last_of('.'); - if(lastPointPos != std::string::npos) + if (paramDown->HasValue()) + { + std::string choiceKey = paramDown->GetChoiceKey( paramDown->GetValue() ); + size_t lastPointPos = choiceKey.find_last_of('.'); + if(lastPointPos != std::string::npos) { - ret = choiceKey.substr(lastPointPos); - } - else + ret = choiceKey.substr(lastPointPos); + } + else { - ret = choiceKey; + ret = choiceKey; } } + else + { + ret = ""; + } + } else if (dynamic_cast<ListViewParameter*>(param)) { ListViewParameter* paramDown = dynamic_cast<ListViewParameter*>(param);