mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Fix crash when creating spatial index from empty layer
libspatialindex library throws an exception when trying to bulk load spatial index and it is given an empty input data stream
This commit is contained in:
parent
f2304c1b15
commit
914cefff95
@ -220,7 +220,7 @@ class QgsSpatialIndexData : public QSharedData
|
||||
// create R-tree
|
||||
SpatialIndex::id_type indexId;
|
||||
|
||||
if ( inputStream )
|
||||
if ( inputStream && inputStream->hasNext() )
|
||||
mRTree = RTree::createAndBulkLoadNewRTree( RTree::BLM_STR, *inputStream, *mStorage, fillFactor, indexCapacity,
|
||||
leafCapacity, dimension, variant, indexId );
|
||||
else
|
||||
|
@ -99,6 +99,13 @@ class TestQgsSpatialIndex : public QObject
|
||||
QVERIFY( fids2.contains( 3 ) );
|
||||
}
|
||||
|
||||
void testInitFromEmptyIterator()
|
||||
{
|
||||
QgsFeatureIterator it;
|
||||
QgsSpatialIndex index( it );
|
||||
// we just test that we survive the above command without exception from libspatialindex raised
|
||||
}
|
||||
|
||||
void testCopy()
|
||||
{
|
||||
QgsSpatialIndex *index = new QgsSpatialIndex;
|
||||
|
Loading…
x
Reference in New Issue
Block a user