Hi Gary
I cannot replicate your problem (tried 2.6 and master). I have attached a
very simple test plugin that first creates an layer and then adds a feature
on a click of a button. With the triggerRepaint() call the canvas is
refreshed correctly (when caching is enabled on or not). Let me know if
that code works for you - maybe your problem is somewhere else or it is
more complex.
Cheers
Martin
On Fri, Jan 23, 2015 at 5:52 AM, Gary Sherman <[email protected]> wrote:
> I have a plugin that makes modifications to a memory layer, then calls
> triggerRepaint() to refresh. Unfortunately, it doesn't refresh the layer.
> If I open the Python console before making the mods, it works from the
> console:
>
> lyr = iface.activeLayer()
> lyr.triggerRepaint()
>
> If I turn off caching in Settings, I don't have a problem with my plugin.
>
> You rendering experts have any ideas?
>
> Thanks,
>
> -gary
>
> --
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> Gary Sherman
>
> Founder, QGIS Project
> Consulting: geoapt.com
> Publishing: locatepress.com
>
> We work virtually anywhere
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>
> _______________________________________________
> Qgis-developer mailing list
> [email protected]
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from qgis.core import *
def classFactory(iface):
return MinimalPlugin(iface)
class MinimalPlugin:
def __init__(self, iface):
self.iface = iface
def initGui(self):
self.action = QAction("Go!", self.iface.mainWindow())
self.action.triggered.connect(self.run)
self.iface.addToolBarIcon(self.action)
def unload(self):
self.iface.removeToolBarIcon(self.action)
del self.action
def run(self):
if not self.iface.activeLayer():
QgsMapLayerRegistry.instance().addMapLayer(QgsVectorLayer("LineString", "x", "memory"))
return
vl = self.iface.activeLayer()
f = QgsFeature()
r = self.iface.mapCanvas().extent()
p1 = QgsPoint(r.xMinimum(),r.yMinimum())
p2 = QgsPoint(r.xMaximum(),r.yMaximum())
f.setGeometry( QgsGeometry.fromPolyline([p1,p2]) )
vl.dataProvider().addFeatures([f])
vl.triggerRepaint()
_______________________________________________
Qgis-developer mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-developer