Navigation Menu

Skip to content

Commit

Permalink
Geometry validator: do not report result summary as error
Browse files Browse the repository at this point in the history
(cherry picked from commit 968e08c)
  • Loading branch information
m-kuhn authored and nyalldawson committed Mar 7, 2019
1 parent 7cedb14 commit 483cf16
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 9 deletions.
22 changes: 20 additions & 2 deletions python/core/auto_generated/qgsgeometryvalidator.sip.in
Expand Up @@ -28,11 +28,29 @@ Constructor for QgsGeometryValidator.

static void validateGeometry( const QgsGeometry &geometry, QVector<QgsGeometry::Error> &errors /Out/, QgsGeometry::ValidationMethod method = QgsGeometry::ValidatorQgisInternal );
%Docstring
Validate geometry and produce a list of geometry errors
Validate geometry and produce a list of geometry errors.
This method blocks the thread until the validation is finished.
%End

signals:
void errorFound( const QgsGeometry::Error & );

void errorFound( const QgsGeometry::Error &error );
%Docstring
Sent when an error has been found during the validation process.

The ``error`` contains details about the error.
%End

void validationFinished( const QString &summary );
%Docstring
Sent when the validation is finished.

The result is in a human readable ``summary``, mentioning
if the validation has been aborted, successfully been validated
or how many errors have been found.

.. versionadded:: 3.6
%End

public slots:
void addError( const QgsGeometry::Error & );
Expand Down
8 changes: 3 additions & 5 deletions src/core/qgsgeometryvalidator.cpp
Expand Up @@ -316,18 +316,16 @@ void QgsGeometryValidator::run()

if ( mStop )
{
emit errorFound( QgsGeometry::Error( QObject::tr( "Geometry validation was aborted." ) ) );
emit validationFinished( QObject::tr( "Geometry validation was aborted." ) );
}
else if ( mErrorCount > 0 )
{
emit errorFound( QgsGeometry::Error( QObject::tr( "Geometry has %1 errors." ).arg( mErrorCount ) ) );
emit validationFinished( QObject::tr( "Geometry has %1 errors." ).arg( mErrorCount ) );
}
#if 0
else
{
emit errorFound( QgsGeometry::Error( QObject::tr( "Geometry is valid." ) ) );
emit validationFinished( QObject::tr( "Geometry is valid." ) );
}
#endif
break;
}
}
Expand Down
24 changes: 22 additions & 2 deletions src/core/qgsgeometryvalidator.h
Expand Up @@ -40,11 +40,31 @@ class CORE_EXPORT QgsGeometryValidator : public QThread
void run() override;
void stop();

//! Validate geometry and produce a list of geometry errors
/**
* Validate geometry and produce a list of geometry errors.
* This method blocks the thread until the validation is finished.
*/
static void validateGeometry( const QgsGeometry &geometry, QVector<QgsGeometry::Error> &errors SIP_OUT, QgsGeometry::ValidationMethod method = QgsGeometry::ValidatorQgisInternal );

signals:
void errorFound( const QgsGeometry::Error & );

/**
* Sent when an error has been found during the validation process.
*
* The \a error contains details about the error.
*/
void errorFound( const QgsGeometry::Error &error );

/**
* Sent when the validation is finished.
*
* The result is in a human readable \a summary, mentioning
* if the validation has been aborted, successfully been validated
* or how many errors have been found.
*
* \since QGIS 3.6
*/
void validationFinished( const QString &summary );

public slots:
void addError( const QgsGeometry::Error & );
Expand Down

0 comments on commit 483cf16

Please sign in to comment.