Bug report #2150

QgsMapCanvas.refresh() doesn't reload WMS layer

Added by luca76 - over 14 years ago. Updated about 13 years ago.

Status:Closed
Priority:Low
Assignee:nobody -
Category:Map Canvas
Affected QGIS version: Regression?:No
Operating System:Windows Easy fix?:No
Pull Request or Patch supplied: Resolution:worksforme
Crashes QGIS or corrupts data: Copied to github as #:12210

Description

In a plugin I add a feature to a PostGIS layer. I have another WMS raster layer connected to this PostGIS layer.

If I invoke the command:

      [[QgsMapCanvas]].refresh()

it refreshes the map but not the WMS layer. A workaround is this (note: 'e' variable is QMouseEvent type):

     self.myCanvas.panAction(e)
     self.myCanvas.panActionEnd(QPoint (e.x(), e.y()))

History

#1 Updated by Marco Hugentobler about 13 years ago

  • Resolution set to worksforme
  • Status changed from Open to Closed

Try to reload the layers before refreshing the canvas (that's how qgisapp does it):

C++:
QgsMapLayerRegistry::instance()->reloadAllLayers();
mMapCanvas->refresh();

Python:
QgsMapLayerRegistry.instance().reloadAllLayers()
qgis.utils.iface.mapCanvas().refresh()

Hope it works (otherwise reopen the ticket)

Also available in: Atom PDF