Skip to content
Permalink
Browse files

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
  • Loading branch information
wonder-sk committed May 8, 2018
1 parent f2304c1 commit 914cefff955c9ee4eaae06b7c9336d3783480650
Showing with 8 additions and 1 deletion.
  1. +1 −1 src/core/qgsspatialindex.cpp
  2. +7 −0 tests/src/core/testqgsspatialindex.cpp
@@ -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;

0 comments on commit 914ceff

Please sign in to comment.
You can’t perform that action at this time.