From f251dee31bf8669ba255c8c29fede5e5731bcf8c Mon Sep 17 00:00:00 2001
From: Rashad Kanavath <rashad.kanavath@c-s.fr>
Date: Wed, 11 Apr 2018 17:35:36 +0200
Subject: [PATCH] BUG: param is optional if mandatory flag is off

---
 Modules/Wrappers/QGIS/src/otbQgisDescriptor.cxx | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/Modules/Wrappers/QGIS/src/otbQgisDescriptor.cxx b/Modules/Wrappers/QGIS/src/otbQgisDescriptor.cxx
index 2a90834577..da3ca1d20e 100644
--- a/Modules/Wrappers/QGIS/src/otbQgisDescriptor.cxx
+++ b/Modules/Wrappers/QGIS/src/otbQgisDescriptor.cxx
@@ -294,11 +294,17 @@ int main(int argc, char* argv[])
 	  std::string optional;
 	  if (param->GetMandatory())
 	    {
+	      // type == ParameterType_StringList check is needed because:
+	      //
+	      // If parameter is mandatory it can have no value
+	      // It is accepted in OTB that, string list could be generated dynamically
+	      // qgis has no such option to handle dynamic values yet..
+	      // So mandatory parameters whose type is StringList is considered optional
 	      optional = param->HasValue() || type == ParameterType_StringList  ? "True" : "False";
 	    }
 	  else
 	    {
-	      optional = "False";
+	      optional = "True";
 	    }
 	  dFile << "|" << default_value << "|" << optional;
 	}
-- 
GitLab