mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-15 00:07:25 -05:00
Check that QgsGeometryCheckContext::project is only used from main thread
This commit is contained in:
parent
43bbaf0c5d
commit
f5638fe63d
@ -8,12 +8,26 @@
|
||||
|
||||
|
||||
|
||||
struct QgsGeometryCheckContext
|
||||
class QgsGeometryCheckContext
|
||||
{
|
||||
%Docstring
|
||||
Base configuration for geometry checks.
|
||||
|
||||
.. note::
|
||||
|
||||
This class is a technology preview and unstable API.
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgsgeometrycheckcontext.h"
|
||||
%End
|
||||
public:
|
||||
QgsGeometryCheckContext( int precision,
|
||||
const QgsCoordinateReferenceSystem &mapCrs,
|
||||
const QgsCoordinateTransformContext &transformContext,
|
||||
const QgsProject *project );
|
||||
const QgsProject *mProject );
|
||||
|
||||
const double tolerance;
|
||||
|
||||
@ -23,7 +37,14 @@ struct QgsGeometryCheckContext
|
||||
|
||||
const QgsCoordinateTransformContext transformContext;
|
||||
|
||||
const QgsProject *project;
|
||||
const QgsProject *project() const;
|
||||
%Docstring
|
||||
The project can be used to resolve additional layers.
|
||||
|
||||
This must only be accessed from the main thread (i.e. do not access from the collectError method)
|
||||
|
||||
.. versionadded:: 3.10
|
||||
%End
|
||||
|
||||
private:
|
||||
QgsGeometryCheckContext( const QgsGeometryCheckContext &rh );
|
||||
|
||||
@ -14,12 +14,19 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "qgsgeometrycheckcontext.h"
|
||||
#include <QThread>
|
||||
|
||||
QgsGeometryCheckContext::QgsGeometryCheckContext( int precision, const QgsCoordinateReferenceSystem &mapCrs, const QgsCoordinateTransformContext &transformContext, const QgsProject *project )
|
||||
: tolerance( std::pow( 10, -precision ) )
|
||||
, reducedTolerance( std::pow( 10, -precision / 2 ) )
|
||||
, mapCrs( mapCrs )
|
||||
, transformContext( transformContext )
|
||||
, project( project )
|
||||
, mProject( project )
|
||||
{
|
||||
}
|
||||
|
||||
const QgsProject *QgsGeometryCheckContext::project() const
|
||||
{
|
||||
Q_ASSERT( qApp->thread() == QThread::currentThread() );
|
||||
return mProject;
|
||||
}
|
||||
|
||||
@ -27,12 +27,13 @@
|
||||
* \note This class is a technology preview and unstable API.
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
struct ANALYSIS_EXPORT QgsGeometryCheckContext
|
||||
class ANALYSIS_EXPORT QgsGeometryCheckContext
|
||||
{
|
||||
public:
|
||||
QgsGeometryCheckContext( int precision,
|
||||
const QgsCoordinateReferenceSystem &mapCrs,
|
||||
const QgsCoordinateTransformContext &transformContext,
|
||||
const QgsProject *project );
|
||||
const QgsProject *mProject );
|
||||
|
||||
/**
|
||||
* The tolerance to allow for in geometry checks.
|
||||
@ -66,7 +67,10 @@ struct ANALYSIS_EXPORT QgsGeometryCheckContext
|
||||
*
|
||||
* \since QGIS 3.10
|
||||
*/
|
||||
const QgsProject *project;
|
||||
const QgsProject *project() const;
|
||||
|
||||
private:
|
||||
const QgsProject *mProject;
|
||||
|
||||
private:
|
||||
#ifdef SIP_RUN
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
#include "qgsfeatureid.h"
|
||||
|
||||
typedef qint64 QgsFeatureId;
|
||||
struct QgsGeometryCheckContext;
|
||||
class QgsGeometryCheckContext;
|
||||
class QgsGeometryCheck;
|
||||
class QgsGeometryCheckError;
|
||||
class QgsMapLayer;
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
class QgsGeometryCheck;
|
||||
class QgsSingleGeometryCheck;
|
||||
|
||||
struct QgsGeometryCheckContext;
|
||||
class QgsGeometryCheckContext;
|
||||
|
||||
/**
|
||||
* \ingroup analysis
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
#include "qgsgeometrycheck.h"
|
||||
|
||||
class QgsGeometryCheckFactory;
|
||||
struct QgsGeometryCheckContext;
|
||||
class QgsGeometryCheckContext;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -36,7 +36,7 @@ void QgsGeometryGapCheck::prepare( const QgsGeometryCheckContext *context, const
|
||||
{
|
||||
if ( configuration.value( QStringLiteral( "allowedGapsEnabled" ) ).toBool() )
|
||||
{
|
||||
QgsVectorLayer *layer = context->project->mapLayer<QgsVectorLayer *>( configuration.value( "allowedGapsLayer" ).toString() );
|
||||
QgsVectorLayer *layer = context->project()->mapLayer<QgsVectorLayer *>( configuration.value( "allowedGapsLayer" ).toString() );
|
||||
mAllowedGapsLayer = layer;
|
||||
mAllowedGapsSource = qgis::make_unique<QgsVectorLayerFeatureSource>( layer );
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user