Bug report #13308
Crash QGIS 2.10.1 after select MultiGeometry features from PostGIS into Temporary Layer
|Affected QGIS version:||2.10.1||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:||fixed/implemented|
|Crashes QGIS or corrupts data:||Yes||Copied to github as #:||21366|
I have created a plugin which selects objects from a PostGIS table by rectangle and puts it into new Memory Layer. Type of geometry in PostGis table - MultiLineString. Adding features to the Memory Layer (its type also MultiLineString) is done successfully. But if you try zoom to Layer and perform any manipulations with map, QGIS is going to crash.
This situation occurs in QGIS 2.10. In 2.8.2 it worked well. Therefore I tried to convert MultiLineString to LineString - QGIS does not crashs, but it is unacceptable for work with some data...
Below is the example code for QGIS python console to reproduce situation and shapefile with some geometry data for tests.
Steps for reproduce:
1. Load shapefile into PostGIS base;
2. Paste code to console, editing parameters for connections. (It will create new memory layer "Result_Layer" and put to it data from PostGIS table "test_shape");
3. Press "Zoom to Layer" to see geometry. (Now we see, that all features have been added);
4. try Zoom In, Zoom Out, Pan map or some any manipulation with map extent in "Result_Layer" area.
5. QGIS CRASH.
from PyQt4.QtCore import * from PyQt4.QtGui import * from qgis.core import * from PyQt4.QtSql import * self = qgis.utils uri = QgsDataSourceURI() uri.setConnection("10.1.1.6", "5432", "Database", "Username", "Password") # "test shape" - Our layer name in base after import from shapefile. # "public" - schema uri.setDataSource("public", "test_shape", "geom", "", "gid") vlayer=QgsVectorLayer(uri.uri(), "tot", "postgres") resultl = QgsVectorLayer("MultiLineString", "Result_select", "memory") QgsMapLayerRegistry.instance().addMapLayer(resultl, True) resultpr = resultl.dataProvider() for feature in vlayer.getFeatures(): resultpr.addFeatures([feature]) self.iface.mapCanvas().refresh() print 'done'
#5 Updated by Mauricio van den Berg about 5 years ago
I suspect I ran into something caused by the same problem.
Reproducible in the following way:
1. Add multilinestring:
@MLayer = QgsVectorLayer("MultiLineString?crs=epsg:28992", "test", "memory") MLayer.startEditing() fet = QgsFeature() geomstring = "MULTILINESTRING((166837.841 577100.866,166836.905 577101.214),(166835.031 577101.913,166834.094 577102.262))" fet.setGeometry(QgsGeometry.fromWkt(geomstring)) MLayer.dataProvider().addFeatures( [fet] ) MLayer.commitChanges() MLayer.updateExtents() QgsMapLayerRegistry.instance().addMapLayer(MLayer)
2. Zoom out very far
3. Click "zoom to layer" on newly added layer
Also crashes in less easily reproducible ways.
I'm also on QGIS 2.10.1, Windows 7 x64
#7 Updated by Jürgen Fischer almost 5 years ago
- Status changed from Open to Feedback
- Assignee deleted (
Original problem only reproducable with 2.10.1 (windows 64bit; second example doesn't crash there here either). 2.8.3 and master seem to work fine. Does enabling/disabling geometry simplification on the layer make a difference?