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

Crash when deleting parent widget before the subwidget #346

Open
jpcima opened this issue Oct 28, 2021 · 6 comments
Open

Crash when deleting parent widget before the subwidget #346

jpcima opened this issue Oct 28, 2021 · 6 comments

Comments

@jpcima
Copy link
Collaborator

jpcima commented Oct 28, 2021

Using DPF 1d756d6 from develop,
in the case of a parent subwidget which has other subwidgets as children, deleting the parent leaves the children having a dangling parentWidget pointer.

The crash happens because of invalid access in SubWidget::PrivateData dtor.
parentWidget->pData->subWidgets.remove(self);

@falkTX
Copy link
Contributor

falkTX commented Oct 28, 2021

You have somewhere/something where this is happening right?

@jpcima
Copy link
Collaborator Author

jpcima commented Oct 28, 2021

spectacle-analyzer in with-new-dpf branch.
The UI keeps a vector fSubWidgets which auto-deletes the elements.
(note that deletion order of vector is undefined)

remark: this would never be a problem is dgl took care of widget ownerships by itself

@falkTX
Copy link
Contributor

falkTX commented Oct 28, 2021

can you be more clear on your latest point?
I thought this was already the case, when the subwidget is created and deleted it removes itself from the parent.
doesnt a widget (top level or sub) delete its children on the destructor?

@falkTX
Copy link
Contributor

falkTX commented Oct 28, 2021

wouldnt this be solved by a simple fSubWidgets.clear() on the (parent) widget destructor?
so it deletes the children before itself.

@jpcima
Copy link
Collaborator Author

jpcima commented Oct 28, 2021

so it deletes the children before itself.

To elaborate, the problem is that it has 3 levels of widgets.
example: UI →FloatingWindow → TextLabel.
Delete FloatingWindow and then TextLabel, and it dies. This wouldn't happen in previous DPF.

doesnt a widget (top level or sub) delete its children on the destructor?

I'm pretty sure it doesn't, just clears the children array. (which are raw pointers)

@falkTX
Copy link
Contributor

falkTX commented Oct 28, 2021

ok but then the owning part makes sense. it doesnt make sense to have to delete the child windows manually.
The UI should destroy child windows, and all the way down as well.

btw, comparing to old DPF is not very helpful, old DPF didn't do a couple of things right.

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

No branches or pull requests

2 participants