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

shared/icon-label: Prevent moc from being appended to global file #11356

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gxalpha
Copy link
Member

@gxalpha gxalpha commented Oct 6, 2024

Description

Like described in 5eb04cd (#11101), this prevents the moc_icon-label.cpp from being included in the global mocs_compilation.cpp file. Looks a bit ridiculous to create a new file for this, but that's just because content-wise icon-label is only a header.

Motivation and Context

Oversight from #11148 due to the fact that there was no .cpp file where this include would usually go.

How Has This Been Tested?

macOS 15
Looked at mocs_compilation.cpp, confirmed that <P4W7YBUBWD/moc_icon-label.cpp> was included previously but no longer is.

Types of changes

  • Tweak (non-breaking change to improve existing functionality)
  • Code cleanup (non-breaking change which makes code smaller or more readable)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

@gxalpha gxalpha added the Enhancement Improvement to existing functionality label Oct 6, 2024
@gxalpha gxalpha requested a review from PatTheMav October 6, 2024 12:41
Copy link
Member

@PatTheMav PatTheMav left a comment

Choose a reason for hiding this comment

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

While the change itself looks correct, I'm unsure whether it's a worthwhile change as it's mainly a cosmetic change.

If icon-label is to be a "header-only" library, then it is correct to make all its function implementations inline (which has become the only meaning of the keyword, mainly to disable the one-definition-rule for the marked functions and variables).

Obviously header-only Qt objects will then incur the compile-time cost of needing their moc-ed code be included globally in the project.

If that is to be fixed, the entire class should be converted into a "non-header" library, its functions moved into the compilation unit and the header converted to its original purpose as a description of the class memory layout.

@gxalpha
Copy link
Member Author

gxalpha commented Jan 16, 2025

This makes sense. I moved the setter functions into the newly created file.

@RytoEX
Copy link
Member

RytoEX commented Jan 16, 2025

I imagine that these files should now be named the same as the class that is defined.

@PatTheMav
Copy link
Member

One could argue that it could keep the current name for consistency with the other elements in the shared directory, but as its contents would be updated to the new design rules established for the frontend directory anyway, it wouldn't hurt to go with the program for all additions.

Renames the icon-label.hpp header to IconLabel to follow the new
convention of files being named the same as the class they contain.
Splits the IconLabel widget header into a header and source file. The
source uses the moc_icon-label include to prevent the moc from being
included in the global mocs_compilation (as described in 5eb04cd).
@gxalpha
Copy link
Member Author

gxalpha commented Jan 17, 2025

Updated the PR to rename the file(s). Left the directory names as-is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Improvement to existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants