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

frontend: Use qobject_cast when casting QObjects #11784

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

Conversation

cg2121
Copy link
Contributor

@cg2121 cg2121 commented Jan 28, 2025

Description

When casting between QObjects, qobject_cast should always be used. This increases performance as there is no RTTI (Run Time Type Information) with qobject_cast, like there is with dynamic_cast.

Motivation and Context

Better code

How Has This Been Tested?

compiled and ran OBS

Types of changes

  • Bug fix (non-breaking change which fixes an issue) -->
  • Performance enhancement (non-breaking change which improves efficiency)

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.

When casting between QObjects, qobject_cast should always be used.
This increases performance as there is no RTTI (Run Time Type Information)
with qobject_cast, like there is with dynamic_cast.
@cg2121 cg2121 force-pushed the replace-dynamic-cast branch from eb3f82d to 5582ea1 Compare January 28, 2025 11:49
@cg2121 cg2121 changed the title frontend: Use qobject_cast instead of dynamic_cast frontend: Use qobject_cast when casting QObjects Jan 28, 2025
@cg2121 cg2121 added Bug Fix Non-breaking change which fixes an issue UI/UX Anything to do with changes or additions to UI/UX elements. labels Jan 28, 2025
@cg2121 cg2121 marked this pull request as draft January 28, 2025 12:50
@cg2121
Copy link
Contributor Author

cg2121 commented Jan 28, 2025

Converting to draft, as #11785 needs to be merged first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Fix Non-breaking change which fixes an issue UI/UX Anything to do with changes or additions to UI/UX elements.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant