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

Fix crashes and issues with SVG rendering #5497

Merged
merged 4 commits into from
Oct 31, 2017

Conversation

nyalldawson
Copy link
Collaborator

@nyalldawson nyalldawson commented Oct 30, 2017

Issues fixed:

(Underlying bugs seems to have been present forever, so fix will need to be backported)

When the svg cache was full, any attempt to render an svg from the
cache would crash QGIS.

Fixes qgis#16643
@nyalldawson nyalldawson reopened this Oct 31, 2017
…gsSvgCache

QgsSvgCache::svgAsPicture was rendering an implicitly shared copy when
the picture had already been cached. It turns out that rendering an
implicitly shared QPicture copy isn't thread safe, and rendering shared
copies simulataneously across different threads leads quickly to a crash.

Accordingly we always detach the QPicture objects returned by
svgAsPicture, so that the returned QPicture is safe to use across threads.

Also add unit tests for this, and a similar unit test to verify that
rendering of QImage based cached copies does *not* suffer the same
issue.

Fixes qgis#17089, qgis#17077
- Remove QgsSvgCacheEntry from public API (is an internal detail only)
- Modernize code
- Make protected QgsSvgCache members private, since this class is not
designed to be subclassed
If file has been modified since the cache, regenerate a new cache
image.

We don't want to check the file modified time too often though,
(e.g., we don't want to check for every point render in a 100k
point file), so use a hardcoded 30 second minimum time between
consecutive file modified checks.

This means that file modifications occuring more often than
every 30 seconds won't be picked up till 30 seconds has elapsed
since the last modification. But at the same time it means that
if the render takes < 30 seconds we'll only check each svg
at most once (and if a render takes > 30 seconds, adding a few
more milliseconds won't hurt!).

Fixes qgis#13565
@nyalldawson nyalldawson changed the title Fix crash when rendering with SVG based symbols and SVG cache is filled Fix crashes and issues with SVG rendering Oct 31, 2017
@nyalldawson
Copy link
Collaborator Author

I'd love a review if someone wants to look over this!

@nirvn
Copy link
Contributor

nirvn commented Oct 31, 2017

I confirm issue 17089 is fixed when applying this PR. Nice.

@saberraz
Copy link
Contributor

I can confirm ##16643 has been resolved in the master, even without this patch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants