-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Safety checks for unregistering map layers from registry
If a map layer which is registered is deleted outside of the layer registry but not unregistered, the layer registry would still happily return a pointer to this layer if queried with its id. Up to now, this caused crashes. Now, the layer will be unregistered and a warning is printed. This patch also contains slight improvements to other parts of the map layer registry.
- Loading branch information
Showing
2 changed files
with
26 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f3bfef4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@m-kuhn nice fixes! it was actually on my agenda for this morning to start building up the map registry unit tests, so very timely :)
f3bfef4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hehe :)
Just wondering, I was working on a QReadWriteLock for QgsMapLayerRegistry. In the end it turned out the real culprit was layers being deleted outside the registry (so what this commit relates to).
In the end, the map layer registry is still accessed from different threads, so it may also be good to harden it for multithreading. I think
QMap
itself is not threadsafe. So far I couldn't definitely relate any crash to this but OTOH if a crash relates to this it's probably a hard-to-reproduce one.f3bfef4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been wondering the exact same thing for QgsCRSCache and QgsCoordinateTransformCache
f3bfef4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@m-kuhn btw, i see a bunch of crashes on my qt5 build following this commit
f3bfef4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually- ignore that. i missed the follow up.
f3bfef4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Followup commit as well?
f3bfef4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah :)