Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QgsVectorLayer 's addFeatures function crashes the app #28514

Closed
qgib opened this issue Dec 2, 2018 · 1 comment
Closed

QgsVectorLayer 's addFeatures function crashes the app #28514

qgib opened this issue Dec 2, 2018 · 1 comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Crash/Data Corruption PyQGIS Related to the PyQGIS API

Comments

@qgib
Copy link
Contributor

qgib commented Dec 2, 2018

Author Name: Mehmet Selim BILGIN (@MSBilgin)
Original Redmine Issue: 20694
Affected QGIS version: 3.4.1
Redmine category:python_bindings_/_sipify


I generated Spatialite point layer that has 1M features by using random point plugin. In python I tried to copy all features to memory layer. Here is the sample code:

@sourceFeatures = self.sourceLayer.getSelectedFeatures()
self.targetLayer.startEditing()
self.targetLayer.addFeatures(sourceFeatures)
@---crashed---

But when i try with 10.000 features this time it successfully adds features. Interestingly, I tried to add 1M features with while loop, this time it succeed. And note that adding operation runs on another QThread.

@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! PyQGIS Related to the PyQGIS API Crash/Data Corruption labels May 25, 2019
@nyalldawson
Copy link
Collaborator

Likely a result of editing a layer from a background thread. This isn't thread safe and is always going to cause random crashes like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Crash/Data Corruption PyQGIS Related to the PyQGIS API
Projects
None yet
Development

No branches or pull requests

2 participants