Deltares / imod-qgis

🗺️🧭 QGIS plugin for iMOD
GNU General Public License v2.0
7 stars 1 forks source link

Viewer widget: self.update_layers() doesn't work in Qgis 3.20 #15

Closed JoerivanEngelen closed 2 years ago

JoerivanEngelen commented 3 years ago

Apparently something goes wrong in a call to self.update_layers():

This throws an error, but Qgis does not crash, the rest of the viewer widget still works.

AttributeError: 'UpdatingQgsMapLayerComboBox' object has no attribute 'project' 
Traceback (most recent call last):
  File "C:\Users/engelen/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\imod\viewer\viewer_widget.py", line 115, in enterEvent
    self.update_layers()
  File "C:\Users/engelen/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\imod\viewer\viewer_widget.py", line 123, in update_layers
    for layer in self.project.mapLayers().values():
AttributeError: 'UpdatingQgsMapLayerComboBox' object has no attribute 'project'
JoerivanEngelen commented 2 years ago

Fixed by not depending on a weird inherited self.project attribute within the widget itsself, instead explicitly pass mapLayers on.