Bug report #13308

Crash QGIS 2.10.1 after select MultiGeometry features from PostGIS into Temporary Layer

Added by Evgeniy Z about 5 years ago. Updated almost 5 years ago.

Status:Closed
Priority:Severe/Regression
Assignee:-
Category:-
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

Description

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'

Test_shapefile.zip (196 KB) Evgeniy Z, 2015-09-01 05:23 AM

Crash.avi (1.37 MB) Evgeniy Z, 2015-09-07 06:23 AM

History

#1 Updated by Salvatore Larosa about 5 years ago

  • Status changed from Open to Feedback

I am not able to reproduce the crash in master version.

Which platform are you using?
Have you tried to reproduce the crash with all plugins deactivated (option --noplugins)?

#2 Updated by Evgeniy Z about 5 years ago

I am using Windows 7 x64, Windows 10 x32.
Now I tried to reproduce the crash with all plugins deactivated - also crash.

#3 Updated by Evgeniy Z about 5 years ago

Demonstration

#4 Updated by Salvatore Larosa about 5 years ago

  • Status changed from Feedback to Open

I can confirm it on Windows and I also can confirm it works fine in LTR version.

#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
4. Crash

Also crashes in less easily reproducible ways.

I'm also on QGIS 2.10.1, Windows 7 x64

#6 Updated by Jürgen Fischer almost 5 years ago

  • Assignee set to Jürgen Fischer

#7 Updated by Jürgen Fischer almost 5 years ago

  • Status changed from Open to Feedback
  • Assignee deleted (Jürgen Fischer)

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?

#8 Updated by Evgeniy Z almost 5 years ago

Jürgen Fischer, No, enabling/disabling geometry simplification on the layer does not make a difference.

#9 Updated by Jürgen Fischer almost 5 years ago

Evgeniy Z wrote:

No, enabling/disabling geometry simplification on the layer does not make a difference.

Can you reproduce it in master?

#10 Updated by Evgeniy Z almost 5 years ago

So in 2.11 master it seems works normal. But I could not track one unexpected crash. I was limited in time.

#11 Updated by Nyall Dawson almost 5 years ago

  • Resolution set to fixed/implemented
  • Status changed from Feedback to Closed

Not reproducible in master. Please reopen if you experience this with 2.12

Also available in: Atom PDF