Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[symbol] fix crasher when rendering a symbol layer subsequent to rendering a geometry generator layer (fixes #19121) #7355

Closed
wants to merge 1 commit into from

Conversation

nirvn
Copy link
Contributor

@nirvn nirvn commented Jul 3, 2018

Description

@m-kuhn , this PR fixes reported issue 19121 (https://issues.qgis.org/issues/19121).

Long story short, the geometry generator's render function was passing on a referenced QgsRenderContext, which modified its geometry(), replacing it with another QgsGeometry that'd scope out, and led to crash when a parent symbol rendered a subsequent symbol layer.

Checklist

Reviewing is a process done by project maintainers, mostly on a volunteer basis. We try to keep the overhead as small as possible and appreciate if you help us to do so by completing the following items. Feel free to ask in a comment if you have troubles with any of them.

  • Commit messages are descriptive and explain the rationale for changes
  • Commits which fix bugs include fixes #11111 in the commit message next to the description
  • Commits which add new features are tagged with [FEATURE] in the commit message
  • Commits which change the UI or existing user workflows are tagged with [needs-docs] in the commit message and contain sufficient information in the commit message to be documented
  • I have read the QGIS Coding Standards and this PR complies with them
  • This PR passes all existing unit tests (test results will be reported by travis-ci after opening this PR)
  • New unit tests have been added for core changes
  • I have run the scripts/prepare-commit.sh script before each commit

@m-kuhn
Copy link
Member

m-kuhn commented Jul 3, 2018

Interesting, I can't follow how the geometry would still be referenced after it scoped out. I think QgsFeature::setGeometry takes a copy?

@nirvn
Copy link
Contributor Author

nirvn commented Jul 3, 2018

In renderFeature(), line 703 sets the QgsRenderContext::geometry() to a constGet() pointer (https://github.com/qgis/QGIS/blob/master/src/core/symbology/qgssymbol.cpp#L703) of a const QgsGeometry declared on line 695 (https://github.com/qgis/QGIS/blob/master/src/core/symbology/qgssymbol.cpp#L695) which scopes out.

Since the QgsRenderContext is passed on as a reference in QgsGeometryGeneratorSymbolLayer::render on line 204 (https://github.com/qgis/QGIS/blob/master/src/core/symbology/qgsgeometrygeneratorsymbollayer.cpp#L204), which itself is passed on as a context for the parent QgsFillSymbol::renderPolygon() loop on line 1787 (https://github.com/qgis/QGIS/blob/master/src/core/symbology/qgssymbol.cpp#L1787), it ends up killing the referred geometry for symbol layers being rendered after the geometry generator layer.

@nirvn
Copy link
Contributor Author

nirvn commented Jul 3, 2018

In addition, as I understand it, even if the geometry wouldn't scope out, we'd still be modifying the context geometry with that of the geometry generated one, which would then mess with the subsequent symbol layers by having those use the wrong geometry.

@m-kuhn
Copy link
Member

m-kuhn commented Jul 3, 2018

Wow, that's superdangerous code there. I wonder if it's not rather the code you are pointing to now, that should be changed, i.e. it should set the old geometry back once its own geometry scopes out.

@nirvn
Copy link
Contributor Author

nirvn commented Jul 3, 2018

@m-kuhn , sounds like an alternative approach that would be more future proof indeed.

Do you want to come up with a commit of your own that'd supersede this here?

@nirvn
Copy link
Contributor Author

nirvn commented Jul 3, 2018

Whatever approach we settle on, we should make sure it doesn't slow down our rendering loop. That's partly why I didn't want to touch renderFeature() to begin with.

@m-kuhn
Copy link
Member

m-kuhn commented Jul 3, 2018

What do you think about #7359 ?

@nirvn
Copy link
Contributor Author

nirvn commented Jul 3, 2018

Superseded by PR #7359 , closing.

@nirvn nirvn closed this Jul 3, 2018
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.

None yet

2 participants