Skip to content

Commit fde813c

Browse files
authored
Merge pull request #7948 from m-kuhn/final
It's the `final` countdown
2 parents d129c2c + b2072d8 commit fde813c

File tree

8 files changed

+110
-118
lines changed

8 files changed

+110
-118
lines changed

python/CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,12 @@ IF(${SIP_VERSION_STR} VERSION_GREATER 4.19.6)
168168
SET(DOCSTRINGSTEMPLATE "")
169169
ENDIF(${SIP_VERSION_STR} VERSION_GREATER 4.19.6)
170170

171+
IF(${SIP_VERSION_STR} VERSION_GREATER 4.19.0)
172+
SET(SIP_FINAL "final")
173+
ELSE(${SIP_VERSION_STR} VERSION_GREATER 4.19.0)
174+
SET(SIP_FINAL "override")
175+
ENDIF(${SIP_VERSION_STR} VERSION_GREATER 4.19.0)
176+
171177
# core module
172178
FILE(GLOB_RECURSE sip_files_core core/*.sip core/*.sip.in)
173179
SET(SIP_EXTRA_FILES_DEPEND ${sip_files_core})

python/core/auto_generated/qgis.sip.in

-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ typedef unsigned long long qgssize;
232232

233233

234234

235-
236235
/************************************************************************
237236
* This file has been generated automatically from *
238237
* *

python/core/auto_generated/qgsvectorlayer.sip.in

+42-73
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,7 @@ Uses :py:class:`QgsExpression`
404404
:return: The expression which will be used to preview features for this layer
405405
%End
406406

407-
virtual QgsVectorDataProvider *dataProvider();
408-
407+
QgsVectorDataProvider *dataProvider() ${SIP_FINAL};
409408

410409
void setProviderEncoding( const QString &encoding );
411410
%Docstring
@@ -443,8 +442,7 @@ Returns the join buffer object.
443442
%End
444443
const QList<QgsVectorLayerJoinInfo> vectorJoins() const;
445444

446-
virtual bool setDependencies( const QSet<QgsMapLayerDependency> &layers );
447-
445+
bool setDependencies( const QSet<QgsMapLayerDependency> &layers ) ${SIP_FINAL};
448446
%Docstring
449447
Sets the list of dependencies.
450448

@@ -457,8 +455,7 @@ Sets the list of dependencies.
457455
.. versionadded:: 3.0
458456
%End
459457

460-
virtual QSet<QgsMapLayerDependency> dependencies() const;
461-
458+
QSet<QgsMapLayerDependency> dependencies() const ${SIP_FINAL};
462459
%Docstring
463460
Gets the list of dependencies. This includes data dependencies set by the user (:py:func:`setDataDependencies`)
464461
as well as dependencies given by the provider
@@ -724,8 +721,7 @@ Ownership is transferred.
724721
Returns point, line or polygon
725722
%End
726723

727-
virtual QgsWkbTypes::Type wkbType() const;
728-
724+
QgsWkbTypes::Type wkbType() const ${SIP_FINAL};
729725
%Docstring
730726
Returns the WKBType or WKBUnknown in case of error
731727
%End
@@ -735,13 +731,10 @@ Returns the WKBType or WKBUnknown in case of error
735731
Returns the provider type for this layer
736732
%End
737733

738-
virtual QgsCoordinateReferenceSystem sourceCrs() const;
739-
740-
virtual QString sourceName() const;
741-
742-
743-
virtual bool readXml( const QDomNode &layer_node, QgsReadWriteContext &context );
734+
QgsCoordinateReferenceSystem sourceCrs() const ${SIP_FINAL};
735+
QString sourceName() const ${SIP_FINAL};
744736

737+
bool readXml( const QDomNode &layer_node, QgsReadWriteContext &context ) ${SIP_FINAL};
745738
%Docstring
746739
Reads vector layer specific state from project file Dom node.
747740

@@ -750,8 +743,7 @@ Reads vector layer specific state from project file Dom node.
750743
Called by :py:func:`QgsMapLayer.readXml()`
751744
%End
752745

753-
virtual bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const;
754-
746+
bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const ${SIP_FINAL};
755747
%Docstring
756748
Write vector layer specific state to project file Dom node.
757749

@@ -760,13 +752,10 @@ Write vector layer specific state to project file Dom node.
760752
Called by :py:func:`QgsMapLayer.writeXml()`
761753
%End
762754

763-
virtual QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const;
764-
765-
virtual QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const;
766-
767-
768-
virtual void resolveReferences( QgsProject *project );
755+
QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const ${SIP_FINAL};
756+
QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const ${SIP_FINAL};
769757

758+
void resolveReferences( QgsProject *project ) ${SIP_FINAL};
770759
%Docstring
771760
Resolve references to other layers (kept as layer IDs after reading XML) into layer objects.
772761

@@ -831,8 +820,8 @@ Load a named style from file/local db/datasource db
831820
:param categories: the style categories to be loaded.
832821
%End
833822

834-
virtual QString loadNamedStyle( const QString &theURI, bool &resultFlag /Out/,
835-
QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories );
823+
QString loadNamedStyle( const QString &theURI, bool &resultFlag /Out/,
824+
QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) ${SIP_FINAL};
836825
%Docstring
837826
Calls loadNamedStyle( theURI, resultFlag, false );
838827
Retained for backward compatibility
@@ -872,8 +861,8 @@ Returns the current auxiliary layer.
872861
%End
873862

874863

875-
virtual bool readSymbology( const QDomNode &layerNode, QString &errorMessage,
876-
QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories );
864+
bool readSymbology( const QDomNode &layerNode, QString &errorMessage,
865+
QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) ${SIP_FINAL};
877866
%Docstring
878867
Read the symbology for the current layer from the Dom node supplied.
879868

@@ -885,8 +874,8 @@ Read the symbology for the current layer from the Dom node supplied.
885874
:return: true in case of success.
886875
%End
887876

888-
virtual bool readStyle( const QDomNode &node, QString &errorMessage,
889-
QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories );
877+
bool readStyle( const QDomNode &node, QString &errorMessage,
878+
QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) ${SIP_FINAL};
890879
%Docstring
891880
Read the style for the current layer from the Dom node supplied.
892881

@@ -898,8 +887,8 @@ Read the style for the current layer from the Dom node supplied.
898887
:return: true in case of success.
899888
%End
900889

901-
virtual bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
902-
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const;
890+
bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
891+
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const ${SIP_FINAL};
903892
%Docstring
904893
Write the symbology for the layer into the docment provided.
905894

@@ -912,8 +901,8 @@ Write the symbology for the layer into the docment provided.
912901
:return: true in case of success.
913902
%End
914903

915-
virtual bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
916-
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const;
904+
bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
905+
const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const ${SIP_FINAL};
917906
%Docstring
918907
Write just the style information for the layer into the document
919908

@@ -938,8 +927,7 @@ Writes the symbology of the layer into the document provided in SLD 1.1 format
938927
:return: true in case of success
939928
%End
940929

941-
virtual bool readSld( const QDomNode &node, QString &errorMessage );
942-
930+
bool readSld( const QDomNode &node, QString &errorMessage ) ${SIP_FINAL};
943931

944932
long featureCount( const QString &legendKey ) const;
945933
%Docstring
@@ -949,8 +937,7 @@ calculated by countSymbolFeatures()
949937
:return: number of features rendered by symbol or -1 if failed or counts are not available
950938
%End
951939

952-
virtual FeatureAvailability hasFeatures() const;
953-
940+
FeatureAvailability hasFeatures() const ${SIP_FINAL};
954941
%Docstring
955942
Determines if this vector layer has features.
956943

@@ -997,8 +984,7 @@ if the geometry type of the new data source matches the current geometry type of
997984
.. versionadded:: 3.2
998985
%End
999986

1000-
virtual QString loadDefaultStyle( bool &resultFlag /Out/ );
1001-
987+
QString loadDefaultStyle( bool &resultFlag /Out/ ) ${SIP_FINAL};
1002988

1003989
QgsVectorLayerFeatureCounter *countSymbolFeatures();
1004990
%Docstring
@@ -1034,8 +1020,7 @@ Returns the string (typically sql) used to define a subset of the layer.
10341020
:return: The subset string or null QString if not implemented by the provider
10351021
%End
10361022

1037-
virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest &request = QgsFeatureRequest() ) const;
1038-
1023+
QgsFeatureIterator getFeatures( const QgsFeatureRequest &request = QgsFeatureRequest() ) const ${SIP_FINAL};
10391024
%Docstring
10401025
Query the layer for features specified in request.
10411026

@@ -1065,8 +1050,7 @@ Query the layer for the features with the given ids.
10651050
Query the layer for the features which intersect the specified rectangle.
10661051
%End
10671052

1068-
virtual bool addFeature( QgsFeature &feature, QgsFeatureSink::Flags flags = 0 );
1069-
1053+
bool addFeature( QgsFeature &feature, QgsFeatureSink::Flags flags = 0 ) ${SIP_FINAL};
10701054

10711055
bool updateFeature( QgsFeature &feature, bool skipDefaultValues = false );
10721056
%Docstring
@@ -1428,14 +1412,12 @@ Set labeling configuration. Takes ownership of the object.
14281412
.. versionadded:: 3.0
14291413
%End
14301414

1431-
virtual bool isEditable() const;
1432-
1415+
bool isEditable() const ${SIP_FINAL};
14331416
%Docstring
14341417
Returns true if the provider is in editing mode
14351418
%End
14361419

1437-
virtual bool isSpatial() const;
1438-
1420+
bool isSpatial() const ${SIP_FINAL};
14391421
%Docstring
14401422
Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeometry
14411423
%End
@@ -1453,26 +1435,22 @@ false otherwise.
14531435
.. versionadded:: 3.0
14541436
%End
14551437

1456-
virtual void reload();
1457-
1438+
void reload() ${SIP_FINAL};
14581439
%Docstring
14591440
Synchronises with changes in the datasource
14601441
%End
14611442

1462-
virtual QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) /Factory/;
1463-
1443+
QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) ${SIP_FINAL} /Factory/;
14641444
%Docstring
14651445
Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context
14661446

14671447
.. versionadded:: 2.4
14681448
%End
14691449

1470-
virtual QgsRectangle extent() const;
1450+
QgsRectangle extent() const ${SIP_FINAL};
1451+
QgsRectangle sourceExtent() const ${SIP_FINAL};
14711452

1472-
virtual QgsRectangle sourceExtent() const;
1473-
1474-
1475-
virtual QgsFields fields() const;
1453+
QgsFields fields() const ${SIP_FINAL};
14761454
%Docstring
14771455
Returns the list of fields of this layer.
14781456
This also includes fields which have not yet been saved to the provider.
@@ -1490,8 +1468,7 @@ Returns list of attribute indexes. i.e. a list from 0 ... fieldCount()
14901468
Returns the list of attributes which make up the layer's primary keys.
14911469
%End
14921470

1493-
virtual long featureCount() const;
1494-
1471+
long featureCount() const ${SIP_FINAL};
14951472
%Docstring
14961473
Returns feature count including changes which have not yet been committed
14971474
If you need only the count of committed features call this method on this layer's provider.
@@ -1715,8 +1692,7 @@ Deletes a list of attribute fields (but does not commit it)
17151692
:return: true if at least one attribute has been deleted
17161693
%End
17171694

1718-
virtual bool addFeatures( QgsFeatureList &features, QgsFeatureSink::Flags flags = 0 );
1719-
1695+
bool addFeatures( QgsFeatureList &features, QgsFeatureSink::Flags flags = 0 ) ${SIP_FINAL};
17201696

17211697
bool deleteFeature( QgsFeatureId fid );
17221698
%Docstring
@@ -1999,8 +1975,7 @@ for the field at `index`.
19991975
.. versionadded:: 3.0
20001976
%End
20011977

2002-
virtual QSet<QVariant> uniqueValues( int fieldIndex, int limit = -1 ) const;
2003-
1978+
QSet<QVariant> uniqueValues( int fieldIndex, int limit = -1 ) const ${SIP_FINAL};
20041979
%Docstring
20051980
Calculates a list of unique values contained within an attribute in the layer. Note that
20061981
in some circumstances when unsaved changes are present for the layer then the returned list
@@ -2034,8 +2009,7 @@ returned list).
20342009
:return: list of unique strings containing substring
20352010
%End
20362011

2037-
virtual QVariant minimumValue( int index ) const;
2038-
2012+
QVariant minimumValue( int index ) const ${SIP_FINAL};
20392013
%Docstring
20402014
Returns the minimum value for an attribute column or an invalid variant in case of error.
20412015
Note that in some circumstances when unsaved changes are present for the layer then the
@@ -2047,8 +2021,7 @@ been changed inside the edit buffer then the previous saved value may be returne
20472021
.. seealso:: :py:func:`uniqueValues`
20482022
%End
20492023

2050-
virtual QVariant maximumValue( int index ) const;
2051-
2024+
QVariant maximumValue( int index ) const ${SIP_FINAL};
20522025
%Docstring
20532026
Returns the maximum value for an attribute column or an invalid variant in case of error.
20542027
Note that in some circumstances when unsaved changes are present for the layer then the
@@ -2112,8 +2085,7 @@ and 1.0 (fully opaque).
21122085
.. versionadded:: 3.0
21132086
%End
21142087

2115-
virtual QString htmlMetadata() const;
2116-
2088+
QString htmlMetadata() const ${SIP_FINAL};
21172089

21182090
void setSimplifyMethod( const QgsVectorSimplifyMethod &simplifyMethod );
21192091
%Docstring
@@ -2181,11 +2153,9 @@ It may also contain embedded expressions.
21812153
.. versionadded:: 3.0
21822154
%End
21832155

2184-
virtual QgsExpressionContext createExpressionContext() const;
2185-
2186-
2187-
virtual QgsExpressionContextScope *createExpressionContextScope() const /Factory/;
2156+
QgsExpressionContext createExpressionContext() const ${SIP_FINAL};
21882157

2158+
QgsExpressionContextScope *createExpressionContextScope() const ${SIP_FINAL} /Factory/;
21892159

21902160
QgsEditFormConfig editFormConfig() const;
21912161
%Docstring
@@ -2596,8 +2566,7 @@ Emitted when the feature count for symbols on this layer has been recalculated.
25962566
%End
25972567

25982568
protected:
2599-
virtual void setExtent( const QgsRectangle &rect );
2600-
2569+
void setExtent( const QgsRectangle &rect ) ${SIP_FINAL};
26012570
%Docstring
26022571
Sets the extent
26032572
%End

scripts/sipify.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ sub detect_non_method_member{
965965
do {no warnings 'uninitialized';
966966
$LINE =~ s/^(\s*template\s*<)(?:class|typename) (\w+>)(.*)$/$1$2$3/;
967967
$LINE =~ s/\s*\boverride\b//;
968-
$LINE =~ s/\s*\bfinal\b//;
968+
$LINE =~ s/\s*\bFINAL\b/ \${SIP_FINAL}/;
969969
$LINE =~ s/\s*\bextern \b//;
970970
$LINE =~ s/\s*\bMAYBE_UNUSED \b//;
971971
$LINE =~ s/\s*\bNODISCARD \b//;

src/core/qgis.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,8 @@ typedef unsigned long long qgssize;
636636
#define MAYBE_UNUSED
637637
#endif
638638

639-
639+
#ifndef FINAL
640+
#define FINAL final
641+
#endif
640642

641643

src/core/qgis_sip.h

+11
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,17 @@
197197
*/
198198
#define SIP_DOC_TEMPLATE
199199

200+
/*
201+
* Sip supports the final keyword since version 4.19.0, earlier than that
202+
* we will have build issues because it tries to override final methods.
203+
*/
204+
#if SIP_VERSION < 0x041300
205+
#if defined FINAL
206+
#undef FINAL
207+
#endif
208+
#define FINAL override
209+
#endif
210+
200211
/*
201212
* Define Python special method (bool, repr, etc.) using the given method or code
202213
* sipify.pl will create a dedicated python file named according to the class

src/core/qgsvectorlayer.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -2863,6 +2863,11 @@ bool QgsVectorLayer::deleteFeatures( const QgsFeatureIds &fids )
28632863
return res;
28642864
}
28652865

2866+
QgsFields QgsVectorLayer::fields() const
2867+
{
2868+
return mFields;
2869+
}
2870+
28662871
QgsAttributeList QgsVectorLayer::primaryKeyAttributes() const
28672872
{
28682873
QgsAttributeList pkAttributesList;

0 commit comments

Comments
 (0)