Bug report #20104
GDAL data provider cache is not cleared after triggerRepaint
|Affected QGIS version:||3.3(master)||Regression?:||No|
|Operating System:||Observed on Windows 7 and Ubuntu 18||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||27926|
While porting Serval plugin  to QGIS 3.2 I have discovered that after a raster datasource is modified and triggerRepaint() is called  the provider cache is not cleared properly. As a consequence, map canvas will display old and new raster cells values at different zoom levels.
When the provider cache is not used, i.e. when QgsGdalProvider::getCachedGdalHandles would be set to only return false, then canvas properly display new cell values at all zoom levels.
Steps to reproduce:
1. Add a raster to QGIS project, for example band1_byte_ct_epsg4326.tif from QGIS test data.
2. In the Python console run:
rlyr = iface.activeLayer() rdp = rlyr.dataProvider() dtype = rdp.dataType(1) rdp.setEditable(True) rblock = QgsRasterBlock(dtype, 1, 1) rblock.setValue(0, 0, 255) rdp.writeBlock(rblock, 1, 0, 0) rdp.setEditable(False) rlyr.triggerRepaint()
3. Zoom in and out a bit to left upper raster corner to see different values of the first cell at different zoom levels.
[GDAL provider] Make sure that setEditable(true) invalides cached GDAL handles to get proper refresh (fixes #20104)