Skip to content

Commit 968e08c

Browse files
committedFeb 20, 2019
Geometry validator: do not report result summary as error
1 parent eceaea8 commit 968e08c

File tree

3 files changed

+45
-9
lines changed

3 files changed

+45
-9
lines changed
 

‎python/core/auto_generated/qgsgeometryvalidator.sip.in

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,29 @@ Constructor for QgsGeometryValidator.
2828

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

3435
signals:
35-
void errorFound( const QgsGeometry::Error & );
36+
37+
void errorFound( const QgsGeometry::Error &error );
38+
%Docstring
39+
Sent when an error has been found during the validation process.
40+
41+
The ``error`` contains details about the error.
42+
%End
43+
44+
void validationFinished( const QString &summary );
45+
%Docstring
46+
Sent when the validation is finished.
47+
48+
The result is in a human readable ``summary``, mentioning
49+
if the validation has been aborted, successfully been validated
50+
or how many errors have been found.
51+
52+
.. versionadded:: 3.6
53+
%End
3654

3755
public slots:
3856
void addError( const QgsGeometry::Error & );

‎src/core/qgsgeometryvalidator.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -349,18 +349,16 @@ void QgsGeometryValidator::run()
349349

350350
if ( mStop )
351351
{
352-
emit errorFound( QgsGeometry::Error( QObject::tr( "Geometry validation was aborted." ) ) );
352+
emit validationFinished( QObject::tr( "Geometry validation was aborted." ) );
353353
}
354354
else if ( mErrorCount > 0 )
355355
{
356-
emit errorFound( QgsGeometry::Error( QObject::tr( "Geometry has %1 errors." ).arg( mErrorCount ) ) );
356+
emit validationFinished( QObject::tr( "Geometry has %1 errors." ).arg( mErrorCount ) );
357357
}
358-
#if 0
359358
else
360359
{
361-
emit errorFound( QgsGeometry::Error( QObject::tr( "Geometry is valid." ) ) );
360+
emit validationFinished( QObject::tr( "Geometry is valid." ) );
362361
}
363-
#endif
364362
break;
365363
}
366364
}

‎src/core/qgsgeometryvalidator.h

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,31 @@ class CORE_EXPORT QgsGeometryValidator : public QThread
4040
void run() override;
4141
void stop();
4242

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

4649
signals:
47-
void errorFound( const QgsGeometry::Error & );
50+
51+
/**
52+
* Sent when an error has been found during the validation process.
53+
*
54+
* The \a error contains details about the error.
55+
*/
56+
void errorFound( const QgsGeometry::Error &error );
57+
58+
/**
59+
* Sent when the validation is finished.
60+
*
61+
* The result is in a human readable \a summary, mentioning
62+
* if the validation has been aborted, successfully been validated
63+
* or how many errors have been found.
64+
*
65+
* \since QGIS 3.6
66+
*/
67+
void validationFinished( const QString &summary );
4868

4969
public slots:
5070
void addError( const QgsGeometry::Error & );

0 commit comments

Comments
 (0)
Please sign in to comment.