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

Remove code duplication in Button #93389

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

KoBeWi
Copy link
Member

@KoBeWi KoBeWi commented Jun 20, 2024

No description provided.

@KoBeWi KoBeWi added this to the 4.x milestone Jun 20, 2024
@KoBeWi KoBeWi requested a review from a team as a code owner June 20, 2024 13:02
Copy link
Member

@AThousandShips AThousandShips left a comment

Choose a reason for hiding this comment

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

This looks good to me, good improvement reducing the risk of errors

Just left a potential improvement suggestion

theme_cache.style_margin_right = 0;
theme_cache.style_margin_top = 0;
theme_cache.style_margin_bottom = 0;

const bool rtl = is_layout_rtl();
if (rtl && has_theme_stylebox(SNAME("normal_mirrored"))) {
Copy link
Member

Choose a reason for hiding this comment

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

Since we have theme cache here I wonder if we can replace this check with a check against:

Suggested change
if (rtl && has_theme_stylebox(SNAME("normal_mirrored"))) {
if (rtl && theme_cache.normal_mirrored.is_valid()) {

I'm not extremely well versed with the theme system but looking at the code it seems it should be equivalent

Copy link
Member Author

@KoBeWi KoBeWi Jun 20, 2024

Choose a reason for hiding this comment

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

Not sure about that, see #84944 (comment)

Copy link
Member

@AThousandShips AThousandShips Jun 20, 2024

Choose a reason for hiding this comment

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

Got it! Though I realized (hence unresolving) that if they aren't equivalent this code will segfault, so even if it's not a 100% drop in it does handle potential crashes, hasn't been a problem in the past though it seems

@akien-mga akien-mga modified the milestones: 4.x, 4.4 Jun 20, 2024
@Repiteo Repiteo modified the milestones: 4.4, 4.x Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants