Skip to content

Commit 6bd3fed

Browse files
committedDec 13, 2022
Make some warnings non-fatal because rasterize algorithm is non-thread safe
and we need the current tests to pass
1 parent 93bbe68 commit 6bd3fed

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed
 

‎src/core/qgsthreadingutils.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535
#define QGIS_PROTECT_QOBJECT_THREAD_ACCESS do {} while(false);
3636
#endif
3737

38+
#if defined(QGISDEBUG)
39+
#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(); }
40+
#else
41+
#define QGIS_PROTECT_QOBJECT_THREAD_ACCESS_NON_FATAL do {} while(false);
42+
#endif
43+
3844

3945
/**
4046
* \ingroup core

‎src/core/vector/qgsvectorlayer.cpp

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,8 @@ void QgsVectorLayer::reload()
442442

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

447448
return new QgsVectorLayerRenderer( this, rendererContext );
448449
}
@@ -720,14 +721,16 @@ void QgsVectorLayer::reselect()
720721

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

725727
return mDataProvider;
726728
}
727729

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

732735
return mDataProvider;
733736
}
@@ -778,7 +781,8 @@ void QgsVectorLayer::setDiagramRenderer( QgsDiagramRenderer *r )
778781

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

783787
return QgsWkbTypes::geometryType( mWkbType );
784788
}
@@ -853,7 +857,8 @@ QgsRectangle QgsVectorLayer::boundingBoxOfSelected() const
853857

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

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

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

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

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

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

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

37253733
return mFields;
37263734
}
@@ -3921,7 +3929,8 @@ int QgsVectorLayer::selectedFeatureCount() const
39213929

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

39263935
return mSelectedFeatureIds;
39273936
}
@@ -4051,7 +4060,8 @@ bool QgsVectorLayer::isEditable() const
40514060

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

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

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

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

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

50015013
return mFeatureBlendMode;
50025014
}

0 commit comments

Comments
 (0)
Please sign in to comment.