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

Don't add QLayouts to QWidgets that already have one #4672

Merged
merged 4 commits into from
Jun 10, 2023

Conversation

Nerixyz
Copy link
Contributor

@Nerixyz Nerixyz commented Jun 8, 2023

Description

Looking at the logs of Chatterino, you sometimes find a QLayout: Attempting to add QLayout "" to QWidget "", which already has a layout. This StackOverflow answer has a good explanation.

If you have a QLayout foo(widget) and a QLayout bar(widget), then the first constructor will set the layout of widget to be foo - calling setLayout. The second constructor will try to set the layout as well, which will fail, because widget's layout was already set, and you can't overwrite the layout if it already exists. The thing to keep in mind: The constructor of a QLayout automatically sets the layout for the widget that's passed in as the parent.

This PR removes these instances (I hope I didn't miss any).

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

src/widgets/helper/EditableModelView.cpp Outdated Show resolved Hide resolved
src/widgets/splits/Split.cpp Outdated Show resolved Hide resolved
@pajlada pajlada self-requested a review June 9, 2023 12:00
@pajlada pajlada enabled auto-merge (squash) June 10, 2023 10:16
@pajlada pajlada merged commit 335dff5 into Chatterino:master Jun 10, 2023
14 checks passed
@Nerixyz Nerixyz deleted the fix/qwidget-with-layout branch June 10, 2023 10:56
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.

None yet

2 participants