Bug report #20104
GDAL data provider cache is not cleared after triggerRepaint
Status: | Closed | ||
---|---|---|---|
Priority: | Normal | ||
Assignee: | Even Rouault | ||
Category: | Data Provider | ||
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 |
Description
While porting Serval plugin [1] to QGIS 3.2 I have discovered that after a raster datasource is modified and triggerRepaint() is called [2] 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.
[1] https://github.com/erpas/serval/tree/QGIS_3_port
[2] https://github.com/erpas/serval/blob/a7ebbaf7653715ebdcaf7b59ee9d069ce895a91b/serval.py#L366
Associated revisions
[GDAL provider] Make sure that setEditable(true) invalides cached GDAL handles to get proper refresh (fixes #20104)
History
#1 Updated by Even Rouault about 6 years ago
- Status changed from Open to In Progress
#2 Updated by Even Rouault about 6 years ago
- % Done changed from 0 to 100
- Status changed from In Progress to Closed
Applied in changeset qgis|e7d15b64951da2d7efba0d32e40cb294aefcd9db.