I guess that an empty list of layers is regarded as acceptable,
as long as the parameter is present in the call.
Perhaps you can use setMinimumNumberInputs to achieve what you
want?
Something like:
self.addParameter(
QgsProcessingParameterMultipleLayers(
self.INPUT_LINES, self.tr <http://self.tr>("Lines"),
QgsProcessing.TypeVectorLine,
optional=False
).setMinimumNumberInputs(1)
)
Håvard
On 04.03.2020 10:02, Jean-Charles Quillet wrote:
> Hello,
>
> I develop a processing algorithm for the toolbox. One of my parameters a list
> of
> vector layers of type line, so in my initAlgorithm function I have this
> statement:
>
> self.addParameter(
> QgsProcessingParameterMultipleLayers(
> self.INPUT_LINES,
> self.tr <http://self.tr>("Lines"),
> QgsProcessing.TypeVectorLine,
> optional=False
> )
> )
>
> However, even if the optional parameter is set to False, it seems the user can
> still set an empty list: so not setting anything actually. So for me, this
> optional parameter doesn't work in this case.
>
> Am I missing something here or is it a bug ? In this last case, I can report
> it
> on github. I'm using QGIS on Windows 3.10.2-A Coruña
>
> Thanks,
>
> Jean-Charles
>
_______________________________________________
QGIS-Developer mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer