Skip to content

Fix Qt6 compatibility issues#5254

Merged
jp9000 merged 2 commits into
obsproject:masterfrom
RytoEX:qt6-fixes
Sep 10, 2021
Merged

Fix Qt6 compatibility issues#5254
jp9000 merged 2 commits into
obsproject:masterfrom
RytoEX:qt6-fixes

Conversation

@RytoEX

@RytoEX RytoEX commented Sep 7, 2021

Copy link
Copy Markdown
Member

Description

There are two commits in this PR. One commit fixes a Qt6-incompatible call to QLocale::setDefault. The other commit fixes a Qt6-incompatible operator usage with two Qt::Modifier instances.


UI: Fix Qt6-incompatible call to QLocale::setDefault

The YouTube integration changes introduced code that does not build on Qt6. The errors were:

  • void QLocale::setDefault(const QLocale &)': cannot convert argument 1 from 'QString' to 'const QLocale &'

  • no suitable user-defined conversion from "QString" to "const QLocale" exists

This commit creates a new QLocale in place from a QString using the QLocale(const QString &name) constructor, and passing that QLocale to QLocale::setDefault.


UI: Fix Qt6-incompatible operator usage

Commit 60d95cb introduced some code that used the + operator on two Qt::Modifier items. Using a pipe operator instead fixes the compilation error on Qt5 and Qt6.


QLocale Docs:

The only docs regarding the Qt::Modifier operator I could find were in QKeySequence:

Motivation and Context

Maintain compatibility with both Qt5 and Qt6 to make switching between the two easier in the future.

Not an urgent fix since we still only support Qt5, so this does not need to be merged during the 27.1.0 RC phase.

How Has This Been Tested?

Clang-format CI check passed on my fork.

Built and tested Undo/Redo on Windows 10 against Qt 5.15.2 and Qt 6.2.0-beta3 to make sure the change to the modifier operator works with both Qt5 and Qt6.

May need testing for the change to the QLocale invocation.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

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.

The YouTube integration changes introduced code that does not build on
Qt6. The errors were:

 * void QLocale::setDefault(const QLocale &)': cannot convert argument 1
   from 'QString' to 'const QLocale &'

 * no suitable user-defined conversion from "QString" to "const QLocale"
   exists

This commit creates a new QLocale in place from a QString using the
`QLocale(const QString &name)` constructor, and passing that QLocale to
QLocale::setDefault.
Commit 60d95cb introduced some code that used the + operator on two
Qt::Modifier items. Using a pipe operator instead fixes the compilation
error on Qt5 and Qt6.
@RytoEX RytoEX added kind/bug Categorizes issue or PR as related to a bug. Seeking Testers Build artifacts on CI labels Sep 7, 2021
@RytoEX RytoEX assigned derrod and unassigned derrod Sep 7, 2021
@RytoEX
RytoEX requested review from WizardCM and derrod September 7, 2021 17:47

@derrod derrod left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me, seems like the current code already doesn't conform to Qt's documentation so it probably only ever worked due to some deprecated feature.

@jp9000
jp9000 merged commit bb5820b into obsproject:master Sep 10, 2021
@RytoEX
RytoEX deleted the qt6-fixes branch September 10, 2021 17:24
@WizardCM WizardCM added this to the OBS Studio 27.1 milestone Sep 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Categorizes issue or PR as related to a bug. Seeking Testers Build artifacts on CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants