Skip to content

Commit a7db0f2

Browse files
authoredOct 21, 2021
avoid detaching QSharedDataPointer<QgsMeshSpatialIndexData> (#45604)
1 parent 6c4b9d1 commit a7db0f2

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed
 

‎src/core/mesh/qgsmeshlayerrenderer.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,9 @@ void QgsMeshLayerRenderer::renderFaceMesh(
428428
if ( context.renderingStopped() )
429429
break;
430430

431+
if ( i >= faces.count() )
432+
continue;
433+
431434
const QgsMeshFace &face = faces[i];
432435
if ( face.size() < 2 )
433436
continue;

‎src/core/mesh/qgsmeshspatialindex.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,11 +409,11 @@ void QgsMeshSpatialIndex::addFace( int faceIndex, const QgsMesh &mesh )
409409
if ( !ok )
410410
return;
411411

412-
const QMutexLocker locker( &d->mMutex );
412+
const QMutexLocker locker( &d.constData()->mMutex );
413413

414414
try
415415
{
416-
d->mRTree->insertData( 0, nullptr, r, faceIndex );
416+
d.constData()->mRTree->insertData( 0, nullptr, r, faceIndex );
417417
}
418418
catch ( Tools::Exception &e )
419419
{
@@ -435,7 +435,7 @@ void QgsMeshSpatialIndex::removeFace( int faceIndex, const QgsMesh &mesh )
435435
{
436436
if ( mesh.face( faceIndex ).isEmpty() )
437437
return;
438-
const QMutexLocker locker( &d->mMutex );
438+
const QMutexLocker locker( &d.constData()->mMutex );
439439
bool ok = false;
440-
d->mRTree->deleteData( faceToRegion( mesh, faceIndex, ok ), faceIndex );
440+
d.constData()->mRTree->deleteData( faceToRegion( mesh, faceIndex, ok ), faceIndex );
441441
}

‎src/core/mesh/qgstriangularmesh.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,8 +639,11 @@ static QSet<int> _nativeElementsFromElements( const QList<int> &indexes, const Q
639639
QSet<int> nativeElements;
640640
for ( const int index : indexes )
641641
{
642-
const int nativeIndex = elementToNativeElements[index];
643-
nativeElements.insert( nativeIndex );
642+
if ( index < elementToNativeElements.count() )
643+
{
644+
const int nativeIndex = elementToNativeElements[index];
645+
nativeElements.insert( nativeIndex );
646+
}
644647
}
645648
return nativeElements;
646649
}

0 commit comments

Comments
 (0)
Please sign in to comment.