GIScience / orstools-qgis-plugin

Plugin for QGIS with a set of tools to use openrouteservice API´s, based on openstreetmap
https://plugins.qgis.org/plugins/ORStools/
MIT License
91 stars 31 forks source link

Got Error on 3.30.0 #177

Closed FlyingEagle closed 1 year ago

FlyingEagle commented 1 year ago

An error has occurred while executing Python code:

TypeError: QgsRubberBand(): argument 2 has unexpected type 'bool' Traceback (most recent call last): File "C:\Users/lw/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ORStools\gui\ORStoolsDialog.py", line 464, in _on_linetool_init self.line_tool = maptools.LineTool(self._iface.mapCanvas()) File "C:\Users/lw/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ORStools\utils\maptools.py", line 51, in init self.rubberBand = QgsRubberBand(self.canvas, False) TypeError: QgsRubberBand(): argument 2 has unexpected type 'bool'

Python version: 3.9.5 (tags/v3.9.5:0a7dcbd, May 3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)] QGIS version: 3.30.0-'s-Hertogenbosch 's-Hertogenbosch, f186b8efe0e

Open Dialog -> Klick Green Plus ...

MichaelsJP commented 1 year ago

@FlyingEagle Thanks for reporting. We'll investigate this asap.

FlyingEagle commented 1 year ago

In Line 51 of file utils\maptools.py, change

self.rubberBand = QgsRubberBand(self.canvas, False)

into this, and it'll work.

self.rubberBand = QgsRubberBand(self.canvas)

MichaelsJP commented 1 year ago

@FlyingEagle Looks good. A PR would be welcome. But make sure to add it as a try:catch to be downwards compatible. :)

koebi commented 1 year ago

@FlyingEagle do you have any idea on what changed such that False isn't allowed anymore?

I couldn't find any version of QgsRubberBand that'd take bool as a second argument, so I assume that there was an implicit type conversion from bool to QgsWkbTypes.GeometryType via the int underlying the latter?

Other than that, I think we should go with QgsRubberBand(self.canvas, QgsWkbType.LineGeometry), sinceQgsWkbType.LineGeometry` seems to be the default for the second argument, and I'd go for explicit over implicit here.