Skip to content

Commit

Permalink
Make some warnings non-fatal because rasterize algorithm is non-threa…
Browse files Browse the repository at this point in the history
…d safe

and we need the current tests to pass
  • Loading branch information
nyalldawson committed Dec 13, 2022
1 parent 93bbe68 commit 6bd3fed
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
6 changes: 6 additions & 0 deletions src/core/qgsthreadingutils.h
Expand Up @@ -35,6 +35,12 @@
#define QGIS_PROTECT_QOBJECT_THREAD_ACCESS do {} while(false);
#endif

#if defined(QGISDEBUG)
#define QGIS_PROTECT_QOBJECT_THREAD_ACCESS_NON_FATAL if ( QThread::currentThread() != thread() ) {qWarning() << QStringLiteral("%2 (%1:%3) is run from a different thread than the object %4 lives in [0x%5 vs 0x%6]" ).arg( QString( __FILE__ ), QString( __FUNCTION__ ), QString::number( __LINE__ ), objectName() ).arg( reinterpret_cast< qint64 >( QThread::currentThread() ), 0, 16 ).arg( reinterpret_cast< qint64 >( thread() ), 0, 16 ).toLocal8Bit().constData(); }
#else
#define QGIS_PROTECT_QOBJECT_THREAD_ACCESS_NON_FATAL do {} while(false);
#endif


/**
* \ingroup core
Expand Down
36 changes: 24 additions & 12 deletions src/core/vector/qgsvectorlayer.cpp
Expand Up @@ -442,7 +442,8 @@ void QgsVectorLayer::reload()

QgsMapLayerRenderer *QgsVectorLayer::createMapRenderer( QgsRenderContext &rendererContext )
{
QGIS_PROTECT_QOBJECT_THREAD_ACCESS
// non fatal for now -- the "rasterize" processing algorithm is not thread safe and calls this
QGIS_PROTECT_QOBJECT_THREAD_ACCESS_NON_FATAL

return new QgsVectorLayerRenderer( this, rendererContext );
}
Expand Down Expand Up @@ -720,14 +721,16 @@ void QgsVectorLayer::reselect()

QgsVectorDataProvider *QgsVectorLayer::dataProvider()
{
QGIS_PROTECT_QOBJECT_THREAD_ACCESS
// non fatal for now -- the "rasterize" processing algorithm is not thread safe and calls this
QGIS_PROTECT_QOBJECT_THREAD_ACCESS_NON_FATAL

return mDataProvider;
}

const QgsVectorDataProvider *QgsVectorLayer::dataProvider() const
{
QGIS_PROTECT_QOBJECT_THREAD_ACCESS
// non fatal for now -- the "rasterize" processing algorithm is not thread safe and calls this
QGIS_PROTECT_QOBJECT_THREAD_ACCESS_NON_FATAL

return mDataProvider;
}
Expand Down Expand Up @@ -778,7 +781,8 @@ void QgsVectorLayer::setDiagramRenderer( QgsDiagramRenderer *r )

QgsWkbTypes::GeometryType QgsVectorLayer::geometryType() const
{
QGIS_PROTECT_QOBJECT_THREAD_ACCESS
// non fatal for now -- the "rasterize" processing algorithm is not thread safe and calls this
QGIS_PROTECT_QOBJECT_THREAD_ACCESS_NON_FATAL

return QgsWkbTypes::geometryType( mWkbType );
}
Expand Down Expand Up @@ -853,7 +857,8 @@ QgsRectangle QgsVectorLayer::boundingBoxOfSelected() const

bool QgsVectorLayer::labelsEnabled() const
{
QGIS_PROTECT_QOBJECT_THREAD_ACCESS
// non fatal for now -- the "rasterize" processing algorithm is not thread safe and calls this
QGIS_PROTECT_QOBJECT_THREAD_ACCESS_NON_FATAL

return mLabelsEnabled && static_cast< bool >( mLabeling );
}
Expand All @@ -867,7 +872,8 @@ void QgsVectorLayer::setLabelsEnabled( bool enabled )

bool QgsVectorLayer::diagramsEnabled() const
{
QGIS_PROTECT_QOBJECT_THREAD_ACCESS
// non fatal for now -- the "rasterize" processing algorithm is not thread safe and calls this
QGIS_PROTECT_QOBJECT_THREAD_ACCESS_NON_FATAL

if ( !mDiagramRenderer || !mDiagramLayerSettings )
return false;
Expand Down Expand Up @@ -1125,7 +1131,8 @@ bool QgsVectorLayer::setSubsetString( const QString &subset )

bool QgsVectorLayer::simplifyDrawingCanbeApplied( const QgsRenderContext &renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint ) const
{
QGIS_PROTECT_QOBJECT_THREAD_ACCESS
// non fatal for now -- the "rasterize" processing algorithm is not thread safe and calls this
QGIS_PROTECT_QOBJECT_THREAD_ACCESS_NON_FATAL

if ( isValid() && mDataProvider && !mEditBuffer && ( isSpatial() && geometryType() != QgsWkbTypes::PointGeometry ) && ( mSimplifyMethod.simplifyHints() & simplifyHint ) && renderContext.useRenderingOptimization() )
{
Expand Down Expand Up @@ -3720,7 +3727,8 @@ bool QgsVectorLayer::deleteFeatures( const QgsFeatureIds &fids, QgsVectorLayer::

QgsFields QgsVectorLayer::fields() const
{
QGIS_PROTECT_QOBJECT_THREAD_ACCESS
// non fatal for now -- the "rasterize" processing algorithm is not thread safe and calls this
QGIS_PROTECT_QOBJECT_THREAD_ACCESS_NON_FATAL

return mFields;
}
Expand Down Expand Up @@ -3921,7 +3929,8 @@ int QgsVectorLayer::selectedFeatureCount() const

const QgsFeatureIds &QgsVectorLayer::selectedFeatureIds() const
{
QGIS_PROTECT_QOBJECT_THREAD_ACCESS
// non fatal for now -- the "rasterize" processing algorithm is not thread safe and calls this
QGIS_PROTECT_QOBJECT_THREAD_ACCESS_NON_FATAL

return mSelectedFeatureIds;
}
Expand Down Expand Up @@ -4051,7 +4060,8 @@ bool QgsVectorLayer::isEditable() const

bool QgsVectorLayer::isSpatial() const
{
QGIS_PROTECT_QOBJECT_THREAD_ACCESS
// non fatal for now -- the "rasterize" processing algorithm is not thread safe and calls this
QGIS_PROTECT_QOBJECT_THREAD_ACCESS_NON_FATAL

QgsWkbTypes::GeometryType t = geometryType();
return t != QgsWkbTypes::NullGeometry && t != QgsWkbTypes::UnknownGeometry;
Expand Down Expand Up @@ -4187,7 +4197,8 @@ void QgsVectorLayer::removeFeatureRendererGenerator( const QString &id )

QList<const QgsFeatureRendererGenerator *> QgsVectorLayer::featureRendererGenerators() const
{
QGIS_PROTECT_QOBJECT_THREAD_ACCESS
// non fatal for now -- the "rasterize" processing algorithm is not thread safe and calls this
QGIS_PROTECT_QOBJECT_THREAD_ACCESS_NON_FATAL

QList< const QgsFeatureRendererGenerator * > res;
for ( const QgsFeatureRendererGenerator *generator : mRendererGenerators )
Expand Down Expand Up @@ -4996,7 +5007,8 @@ void QgsVectorLayer::setFeatureBlendMode( QPainter::CompositionMode featureBlend

QPainter::CompositionMode QgsVectorLayer::featureBlendMode() const
{
QGIS_PROTECT_QOBJECT_THREAD_ACCESS
// non fatal for now -- the "rasterize" processing algorithm is not thread safe and calls this
QGIS_PROTECT_QOBJECT_THREAD_ACCESS_NON_FATAL

return mFeatureBlendMode;
}
Expand Down

0 comments on commit 6bd3fed

Please sign in to comment.