Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
avoid detaching QSharedDataPointer<QgsMeshSpatialIndexData> (#45604)
  • Loading branch information
vcloarec committed Oct 21, 2021
1 parent 6c4b9d1 commit a7db0f2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/core/mesh/qgsmeshlayerrenderer.cpp
Expand Up @@ -428,6 +428,9 @@ void QgsMeshLayerRenderer::renderFaceMesh(
if ( context.renderingStopped() )
break;

if ( i >= faces.count() )
continue;

const QgsMeshFace &face = faces[i];
if ( face.size() < 2 )
continue;
Expand Down
8 changes: 4 additions & 4 deletions src/core/mesh/qgsmeshspatialindex.cpp
Expand Up @@ -409,11 +409,11 @@ void QgsMeshSpatialIndex::addFace( int faceIndex, const QgsMesh &mesh )
if ( !ok )
return;

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

try
{
d->mRTree->insertData( 0, nullptr, r, faceIndex );
d.constData()->mRTree->insertData( 0, nullptr, r, faceIndex );
}
catch ( Tools::Exception &e )
{
Expand All @@ -435,7 +435,7 @@ void QgsMeshSpatialIndex::removeFace( int faceIndex, const QgsMesh &mesh )
{
if ( mesh.face( faceIndex ).isEmpty() )
return;
const QMutexLocker locker( &d->mMutex );
const QMutexLocker locker( &d.constData()->mMutex );
bool ok = false;
d->mRTree->deleteData( faceToRegion( mesh, faceIndex, ok ), faceIndex );
d.constData()->mRTree->deleteData( faceToRegion( mesh, faceIndex, ok ), faceIndex );
}
7 changes: 5 additions & 2 deletions src/core/mesh/qgstriangularmesh.cpp
Expand Up @@ -639,8 +639,11 @@ static QSet<int> _nativeElementsFromElements( const QList<int> &indexes, const Q
QSet<int> nativeElements;
for ( const int index : indexes )
{
const int nativeIndex = elementToNativeElements[index];
nativeElements.insert( nativeIndex );
if ( index < elementToNativeElements.count() )
{
const int nativeIndex = elementToNativeElements[index];
nativeElements.insert( nativeIndex );
}
}
return nativeElements;
}
Expand Down

0 comments on commit a7db0f2

Please sign in to comment.