Skip to content

Fix crash when adding map sketches on older QGIS release and add a test case#715

Merged
ValentinBuira merged 3 commits intomasterfrom
test-map-sketches
Jun 18, 2025
Merged

Fix crash when adding map sketches on older QGIS release and add a test case#715
ValentinBuira merged 3 commits intomasterfrom
test-map-sketches

Conversation

@ValentinBuira
Copy link
Contributor

Fix crash when adding a map sketches layer because we can't use the new fancy enum in older QGIS release.

Also add a test case for this

image

@JanCaha
Copy link
Contributor

JanCaha commented Jun 18, 2025

Not sure if we want to default to older enum type by default or if we want have something like:

 if Qgis.versionInt() >= 34000:
        symbol_layer.setDataDefinedProperty(QgsSymbolLayer.Property.StrokeColor, QgsProperty.fromExpression('"color"'))
    else:
        symbol_layer.setDataDefinedProperty(QgsSymbolLayer.PropertyStrokeColor, QgsProperty.fromExpression('"color"'))

This should work with both older versions of QGIS and also in the future if the QgsSymbolLayer.PropertyStrokeColor gets ever removed. Not sure if we have guideline for something like this.

Besides that, it looks all good.

@JanCaha
Copy link
Contributor

JanCaha commented Jun 18, 2025

Not exactly sure, why the test is failing. It should work the code seems to be fine ...

@ValentinBuira
Copy link
Contributor Author

This should work with both older versions of QGIS and also in the future if the QgsSymbolLayer.PropertyStrokeColor gets ever removed. Not sure if we have guideline for something like this.

I don't think it will be ever removed with the don't break API rule in QGIS, but the new entries to the enum will be accessed with QgsSymbolLayer.Property.NewPropertyName

@JanCaha
Copy link
Contributor

JanCaha commented Jun 18, 2025

Ok, lets leave it as it is.

Just fix the test then ;-)

@ValentinBuira ValentinBuira merged commit 8840014 into master Jun 18, 2025
7 checks passed
@ValentinBuira ValentinBuira deleted the test-map-sketches branch June 18, 2025 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants