Greetings Everyone,
I'm playing around with a plugin that's supposed to receive GPS Data over a
TCP socket and then once a new point is received the Vector Memory/Scratch
Layer has all features removed and a new Point feature added. I have a
worker thread running that processes the incoming TCP socket data (rate of
about 10 Hz) and then runs a function called addPoint. Currently the plugin
works great if I don't call addPoint and just print the contents of the
received message. Once I add in the addPoint function, however, the plugin
works for a bit (30-60 seconds) and then QGIS crashes.
My addPoint function is as follows:
def addPoint(self, point):
self.layer.startEditing()
caps = self.layer.dataProvider().capabilities()
if caps & QgsVectorDataProvider.DeleteFeatures:
for feat in self.layer.getFeatures():
self.layer.deleteFeature(feat.id())
if caps & QgsVectorDataProvider.AddFeatures:
feat = QgsFeature(self.layer.pendingFields())
feat.setGeometry(QgsGeometry.fromPoint(point))
(res, outFeats) = self.layer.dataProvider().addFeatures([feat])
self.layer.commitChanges()
Perhaps the issue is because I'm entering/exiting Edit mode so often (10
Hz)? Is there a more efficient method to accomplish what I'm doing? Or maybe
it's some sort of threading conflict?
Thanks,
Josh Q
_______________________________________________
QGIS-Developer mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer