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

Avoid double free if QgsMapToolCapture is deleted after map canvas #48592

Merged
merged 4 commits into from
May 22, 2022

Conversation

nyalldawson
Copy link
Collaborator

No description provided.

owned by a parent QObject

E.g. QGraphicsItem subclasses are not QObjects themselves, but
are owned by a QObject QGraphicsScene. Depending on whether the
graphics item is deleted first or the scene, we can end up with
a double-free situation.

Fix this by creating a QObjectParentUniquePtr smart pointer which
is automatically nulled if the parent QObject (e.g. the QGraphicsScene)
is deleted first.

(Adapted from existing QObjectUniquePtr logic and logic in
QgsSnapIndicator)
@github-actions github-actions bot added the GUI/UX Related to QGIS application GUI or User Experience label May 18, 2022
@github-actions github-actions bot added this to the 3.26.0 milestone May 18, 2022
{
if ( p && !mParent )
{
qWarning() << "Assigning pointer to QObjectParentUniquePtr with nullptr parent.";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You meant to use qWarning and not QgsDebugMsg here? Just checking.

Copy link
Collaborator Author

@nyalldawson nyalldawson May 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep -- it won't show unless something is very wrong, and I want the extra "in your face"-ness which qWarning gives us

@nyalldawson nyalldawson merged commit b536c31 into qgis:master May 22, 2022
@nyalldawson nyalldawson deleted the owned_pointer branch May 22, 2022 03:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Crash/Data Corruption GUI/UX Related to QGIS application GUI or User Experience
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants