Skip to content

Conversation

@bmjcode
Copy link
Collaborator

@bmjcode bmjcode commented Apr 30, 2025

Adding a widget to a layout changes its parent to the widget on which the layout is installed. Here the layout is on self.mainwidget, and the tab bar and view manager become its children. Thus if mainwidget is a local variable, the tab bar and view manager are garbage-collected when the constructor returns and mainwidget goes out of scope, even though they were constructed with the MainWindow instance as their parent.

Hopefully this finally fixes the infamous #1467.

Adding a widget to a layout changes its parent to the widget on which
the layout is installed. Here the layout is on self.mainwidget, and the
tab bar and view manager become its children. Thus if mainwidget is a
local variable, the tab bar and view manager are garbage-collected when
the constructor returns and mainwidget goes out of scope, even though
they were constructed with the MainWindow instance as their parent.

Hopefully this finally fixes the infamous frescobaldi#1467.
@bmjcode bmjcode force-pushed the mainwidget-parent branch from 86d436e to e98b689 Compare April 30, 2025 00:10
@fedelibre
Copy link
Member

@bmjcode Feel free to merge this if ready.

I would then make a 4.0.2 release soon and close #1467 . If it's not fixed, we'll see soon new issues.
Does this fix only #1467 or maybe other similar issues?

@bmjcode bmjcode merged commit a342baf into frescobaldi:master May 4, 2025
@bmjcode bmjcode deleted the mainwidget-parent branch May 4, 2025 00:08
@bmjcode
Copy link
Collaborator Author

bmjcode commented May 4, 2025

Does this fix only #1467 or maybe other similar issues?

I think all the "wrapped C/C++ object has been deleted" errors share the same root cause, so this should fix all of them.

Edit: Assuming I'm right about what the problem is, which is always a big if. :)

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.

2 participants