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

Switch to Qt 6 and C++17 #6516

Merged
merged 3 commits into from
Sep 19, 2024
Merged

Conversation

davidebeatrici
Copy link
Member

Requires thorough testing, especially the regex changes.

@davidebeatrici

This comment was marked as resolved.

Copy link
Member

@Krzmbrzl Krzmbrzl left a comment

Choose a reason for hiding this comment

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

Haven't looked through all changes yet.

How did you manage the C++17 dependency though?

@@ -195,7 +195,7 @@ bool Group::appliesToUser(const Channel &currentChannel, const Channel &aclChann
channel = channel->cParent;
}

int requiredChannelIndex = currentChannelHierarchy.indexOf(contextChannel);
auto requiredChannelIndex = currentChannelHierarchy.indexOf(contextChannel);
Copy link
Member

Choose a reason for hiding this comment

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

Invalid use of auto

@@ -211,10 +211,10 @@ bool Group::appliesToUser(const Channel &currentChannel, const Channel &aclChann
return RET_FALSE;
}

const int minDepth = requiredChannelIndex + minDescendantLevel;
const int maxDepth = requiredChannelIndex + maxDescendantLevel;
const auto minDepth = requiredChannelIndex + minDescendantLevel;
Copy link
Member

Choose a reason for hiding this comment

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

Invalid use of auto

const int minDepth = requiredChannelIndex + minDescendantLevel;
const int maxDepth = requiredChannelIndex + maxDescendantLevel;
const auto minDepth = requiredChannelIndex + minDescendantLevel;
const auto maxDepth = requiredChannelIndex + maxDescendantLevel;
Copy link
Member

Choose a reason for hiding this comment

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

Invalid use of auto


const int totalDepth = homeChannelHierarchy.count() - 1;
const auto totalDepth = homeChannelHierarchy.count() - 1;
Copy link
Member

Choose a reason for hiding this comment

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

Invalid use of auto

@@ -154,15 +154,15 @@ void ProcessResolver::doResolve() {
QByteArray cmdline = f.readAll();
f.close();

int nul = cmdline.indexOf('\0');
const auto nul = cmdline.indexOf('\0');
Copy link
Member

Choose a reason for hiding this comment

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

Invalid use of auto

@@ -580,7 +583,11 @@ QString ShortcutDelegate::displayText(const QVariant &item, const QLocale &loc)
}
}
default:
#if QT_VERSION >= 0x060000
Copy link
Member

Choose a reason for hiding this comment

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

Keep only Qt6

@@ -849,7 +856,11 @@ QTreeWidgetItem *GlobalShortcutConfig::itemForShortcut(const Shortcut &sc) const
::GlobalShortcut *gs = GlobalShortcutEngine::engine->qmShortcuts.value(sc.iIndex);

item->setData(0, Qt::DisplayRole, static_cast< unsigned int >(sc.iIndex));
#if QT_VERSION >= 0x060000
Copy link
Member

Choose a reason for hiding this comment

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

Keep only Qt6

@@ -953,7 +964,7 @@ void GlobalShortcutEngine::remap() {
sk->gs = gs;

foreach (const QVariant &button, sc.qlButtons) {
int idx = qlButtonList.indexOf(button);
auto idx = qlButtonList.indexOf(button);
Copy link
Member

Choose a reason for hiding this comment

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

Invalid use of auto

@@ -1026,7 +1037,7 @@ bool GlobalShortcutEngine::handleButton(const QVariant &button, bool down) {
}
}

int idx = qlButtonList.indexOf(button);
const auto idx = qlButtonList.indexOf(button);
Copy link
Member

Choose a reason for hiding this comment

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

Invalid use of auto

@@ -193,25 +193,33 @@ void GlobalShortcutWin::registerMetaTypes() {
registered = true;

qRegisterMetaType< InputHid >();
#if QT_VERSION < 0x060000
Copy link
Member

Choose a reason for hiding this comment

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

Not needed if we fully switch

@davidebeatrici
Copy link
Member Author

I would like to keep support for Qt 5 at least until the next stable release, but don't want to write a preprocessor block for every qsizetype (int64_t) vs int instance.

I followed Qt's recommendation:

Note: If you want to build against both Qt 5 and Qt 6, the auto keyword is a good solution to cover signature differences between the versions.

@Krzmbrzl
Copy link
Member

Why do you want to keep Qt5 support? It is EOL already and Qt6 has been around for so long as to be available on all platforms that we want to support (afaik) 🤔

@davidebeatrici
Copy link
Member Author

Right:

https://www.qt.io/blog/qt-5.15-extended-support-for-subscription-license-holders

In that case we have to prepare a Qt 6 vcpkg environment.

@Krzmbrzl
Copy link
Member

In that case we have to prepare a Qt 6 vcpkg environment.

Yep

Coming back to the C++17 requirement though: how did you manage it so that nothing breaks? 🤔

@davidebeatrici
Copy link
Member Author

Well, there is one thing "broken": we use the <codecvt> header to convert between UTF-8 and UTF-16 and it was deprecated in C++17, resulting in a warning.

Unfortunately there is no standard replacement, we'll have to rely on something like https://github.com/nemtrif/utfcpp.

As for ZeroC Ice: the headers that make use of std::binary_function and std::unary_function are patched in our fork (which we use in our vcpkg port):

mumble-voip/ice@bc7eb3e
mumble-voip/ice@e1e88d8

Upstream seems to have fixed the issue in v3.7.7: zeroc-ice/ice@bc2762e

In conclusion: before merging this PR we should build with Qt 6 to make sure that there are no issues on any platforms.

@davidebeatrici
Copy link
Member Author

#6517

@davidebeatrici
Copy link
Member Author

E: Unable to locate package qt6-svg-dev

The name was libqt6svg6-dev before...

Comment on lines -31 to -32
UpdateEntry() = default;

Copy link
Member Author

@davidebeatrici davidebeatrici Jul 23, 2024

Choose a reason for hiding this comment

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

I added this change by mistake, it's supposed to fix a separate issue:

src/mumble/PluginUpdater.cpp:49:18: error: no matching constructor for initialization of 'UpdateEntry'
   49 |                                         UpdateEntry entry = { plugin->getID(), updateURL, updateURL.fileName(), 0 };
      |                                                     ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/mumble/PluginUpdater.h:30:8: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 4 were provided
   30 | struct UpdateEntry {
      |        ^~~~~~~~~~~
src/mumble/PluginUpdater.h:30:8: note: candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 4 were provided
   30 | struct UpdateEntry {
      |        ^~~~~~~~~~~
src/mumble/PluginUpdater.h:31:2: note: candidate constructor not viable: requires 0 arguments, but 4 were provided
   31 |         UpdateEntry() = default;
      |         ^

OpenMandrivaAssociation/mumble@df75805

@davidebeatrici
Copy link
Member Author

E: Unable to locate package qt6-svg-dev

The name was libqt6svg6-dev before...

Despite libqt6svg6-dev being installed just fine, CMake is unable to find Qt's "Svg" component.

The package seemingly contains the required files, which leads me to think something is broken.

Unfortunately we cannot switch to Ubuntu 24.04 in Azure Pipelines because not publicly available yet: actions/runner-images#9848 (comment)

@davidebeatrici
Copy link
Member Author

I ended up adding 24.04's repository and installing the Qt packages from there.

@Krzmbrzl
Copy link
Member

We can't exclusively use 24.04 though. At least we have to also have a CI for 22.04

@davidebeatrici
Copy link
Member Author

The base system is still 22.04, but I can see why we should test the Qt packages that are normally provided with it.

Unfortunately we have no choice other than reporting the bug upstream and hoping for a quick fix.

@Krzmbrzl
Copy link
Member

Yeah, we should report it. However, until this is fixed I think we should just wait with merging this PR. At least for a couple of weeks to see what the maintainers will do with the reported issue. 👀

@davidebeatrici
Copy link
Member Author

I created a VM with a minimal Ubuntu 22.04 installation and quickly found out what the issue was: missing libgl-dev.

Our build log actually gave us a hint, but I missed it as I focused on the specific component (Svg). Turns out the find_pkg() error is inaccurate: NONE of the GUI-related components were found; or rather, they were ignored due to the missing dependency.

-- Could NOT find OpenGL (missing: OPENGL_INCLUDE_DIR) 
CMake Error at cmake/pkg-utils.cmake:87 (message):
  Qt6 component not found: Svg
Call Stack (most recent call first):
  src/mumble/CMakeLists.txt:76 (find_pkg)

A minimal CMake project with the standard find_package() call reveals a more accurate log:

-- Could NOT find OpenGL (missing: OPENGL_INCLUDE_DIR) 
-- Could NOT find WrapOpenGL (missing: WrapOpenGL_FOUND) 
CMake Warning at /usr/lib/x86_64-linux-gnu/cmake/Qt6/Qt6Config.cmake:219 (find_package):
  Found package configuration file:

    /usr/lib/x86_64-linux-gnu/cmake/Qt6Gui/Qt6GuiConfig.cmake

  but it set Qt6Gui_FOUND to FALSE so package "Qt6Gui" is considered to be
  NOT FOUND.  Reason given by package:

  Qt6Gui could not be found because dependency WrapOpenGL could not be found.

Call Stack (most recent call first):
  CMakeLists.txt:5 (find_package)


-- Could NOT find OpenGL (missing: OPENGL_INCLUDE_DIR) 
-- Could NOT find WrapOpenGL (missing: WrapOpenGL_FOUND) 
CMake Warning at /usr/share/cmake-3.22/Modules/CMakeFindDependencyMacro.cmake:47 (find_package):
  Found package configuration file:

    /usr/lib/x86_64-linux-gnu/cmake/Qt6Gui/Qt6GuiConfig.cmake

  but it set Qt6Gui_FOUND to FALSE so package "Qt6Gui" is considered to be
  NOT FOUND.  Reason given by package:

  Qt6Gui could not be found because dependency WrapOpenGL could not be found.

Call Stack (most recent call first):
  /usr/lib/x86_64-linux-gnu/cmake/Qt6/QtPublicDependencyHelpers.cmake:14 (find_dependency)
  /usr/lib/x86_64-linux-gnu/cmake/Qt6Svg/Qt6SvgDependencies.cmake:96 (_qt_internal_find_dependencies)
  /usr/lib/x86_64-linux-gnu/cmake/Qt6Svg/Qt6SvgConfig.cmake:50 (include)
  /usr/lib/x86_64-linux-gnu/cmake/Qt6/Qt6Config.cmake:219 (find_package)
  CMakeLists.txt:5 (find_package)


CMake Warning at /usr/lib/x86_64-linux-gnu/cmake/Qt6/Qt6Config.cmake:219 (find_package):
  Found package configuration file:

    /usr/lib/x86_64-linux-gnu/cmake/Qt6Svg/Qt6SvgConfig.cmake

  but it set Qt6Svg_FOUND to FALSE so package "Qt6Svg" is considered to be
  NOT FOUND.  Reason given by package:

  Qt6Svg could not be found because dependency Qt6Gui could not be found.

Call Stack (most recent call first):
  CMakeLists.txt:5 (find_package)


-- Could NOT find OpenGL (missing: OPENGL_INCLUDE_DIR) 
-- Could NOT find WrapOpenGL (missing: WrapOpenGL_FOUND) 
CMake Warning at /usr/share/cmake-3.22/Modules/CMakeFindDependencyMacro.cmake:47 (find_package):
  Found package configuration file:

    /usr/lib/x86_64-linux-gnu/cmake/Qt6Gui/Qt6GuiConfig.cmake

  but it set Qt6Gui_FOUND to FALSE so package "Qt6Gui" is considered to be
  NOT FOUND.  Reason given by package:

  Qt6Gui could not be found because dependency WrapOpenGL could not be found.

Call Stack (most recent call first):
  /usr/lib/x86_64-linux-gnu/cmake/Qt6/QtPublicDependencyHelpers.cmake:14 (find_dependency)
  /usr/lib/x86_64-linux-gnu/cmake/Qt6Widgets/Qt6WidgetsDependencies.cmake:96 (_qt_internal_find_dependencies)
  /usr/lib/x86_64-linux-gnu/cmake/Qt6Widgets/Qt6WidgetsConfig.cmake:50 (include)
  /usr/lib/x86_64-linux-gnu/cmake/Qt6/Qt6Config.cmake:219 (find_package)
  CMakeLists.txt:5 (find_package)


CMake Warning at /usr/lib/x86_64-linux-gnu/cmake/Qt6/Qt6Config.cmake:219 (find_package):
  Found package configuration file:

    /usr/lib/x86_64-linux-gnu/cmake/Qt6Widgets/Qt6WidgetsConfig.cmake

  but it set Qt6Widgets_FOUND to FALSE so package "Qt6Widgets" is considered
  to be NOT FOUND.  Reason given by package:

  Qt6Widgets could not be found because dependency Qt6Gui could not be found.

Call Stack (most recent call first):
  CMakeLists.txt:5 (find_package)


CMake Error at CMakeLists.txt:5 (find_package):
  Found package configuration file:

    /usr/lib/x86_64-linux-gnu/cmake/Qt6/Qt6Config.cmake

  but it set Qt6_FOUND to FALSE so package "Qt6" is considered to be NOT
  FOUND.  Reason given by package:

  Failed to find Qt component "Gui".

  Expected Config file at
  "/usr/lib/x86_64-linux-gnu/cmake/Qt6Gui/Qt6GuiConfig.cmake" exists

  Failed to find Qt component "Svg".

  Expected Config file at
  "/usr/lib/x86_64-linux-gnu/cmake/Qt6Svg/Qt6SvgConfig.cmake" exists

  Failed to find Qt component "Widgets".

  Expected Config file at
  "/usr/lib/x86_64-linux-gnu/cmake/Qt6Widgets/Qt6WidgetsConfig.cmake" exists

Please note that libgl-dev is pulled in automatically with the packages from Ubuntu 24.04, meaning that it's effectively a bug that should be reported.

@davidebeatrici
Copy link
Member Author

Formatted with clang-format 10, in order for CI to succeed.

@davidebeatrici davidebeatrici force-pushed the qt6-support branch 2 times, most recently from a1084c4 to f5f46d2 Compare September 17, 2024 03:37
@davidebeatrici davidebeatrici merged commit 7101060 into mumble-voip:master Sep 19, 2024
13 checks passed
@davidebeatrici davidebeatrici deleted the qt6-support branch September 19, 2024 03:20
@botanegg
Copy link
Contributor

Try it on archlinux from aur

Seems like it laggy on first time Settings window was opened

@davidebeatrici
Copy link
Member Author

It feels sluggish when you open the Settings window, but only the first time?

@botanegg
Copy link
Contributor

botanegg commented Sep 27, 2024

Found it (Mumble (1.6.0) from 5782f61 with Qt 6.7.2)
At the time I open the Settings window it writes to console next log

<W>2024-09-27 23:23:08.481   OpenType support missing for "Ubuntu", script 11
<W>2024-09-27 23:23:08.484   OpenType support missing for "Droid Sans", script 11
<W>2024-09-27 23:23:08.484   OpenType support missing for "DejaVu Sans", script 11

..... <removed more than 3000 lines> ...

<W>2024-09-27 23:23:09.948   OpenType support missing for "Input Mono", script 17
<W>2024-09-27 23:23:09.948   OpenType support missing for "Input Serif", script 17

~1.5s total :)

@Hartmnt
Copy link
Member

Hartmnt commented Sep 27, 2024

Probably related #4927 and maybe even #5922

@botanegg
Copy link
Contributor

Will recheck on latest release with qt5 (not on master)

@botanegg
Copy link
Contributor

Its OK with Mumble (1.5.634) with Qt 5.15.15

only 1 line in console log

<W>2024-09-27 23:34:10.102   OpenType support missing for "Droid Sans", script 11

@Hartmnt
Copy link
Member

Hartmnt commented Sep 27, 2024

Yea, I think this will be a very hard to track race condition kind of bug. Depending on exact version and system configuration and stuff...

@botanegg
Copy link
Contributor

botanegg commented Sep 27, 2024

Fonts scan triggered by

QSize ms = cw->minimumSizeHint();

for LookConfig

UPD: yep, look like a race

@Krzmbrzl
Copy link
Member

To me this kinda looks like a Qt issue because afaict we are not doing any explicit font manipulation kn our end 👀

@Hartmnt
Copy link
Member

Hartmnt commented Sep 28, 2024

To me this kinda looks like a Qt issue because afaict we are not doing any explicit font manipulation kn our end 👀

From what I have read so far, this is a combination of our stylesheet usage and the inability of Qt to properly maintain their stylesheet support. Trying to fix this will likely mean wrestling with Qt for like two weeks again. Additionally, one needs to reliably recreate this bug, which I have not managed to do so far

@Guanran928
Copy link

Guanran928 commented Oct 1, 2024

Hi, are there any plans for updating the documentation for macOS and Windows?


qt5-base[mysqlplugin]
qt5-base[postgresqlplugin]
qt5-svg
qt5-tools
qt5-translations

@davidebeatrici
Copy link
Member Author

Sure, should've been done in #6572.

@Krzmbrzl
Copy link
Member

Krzmbrzl commented Oct 1, 2024

It's (kinda) done via #6588

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client feature-request This issue or PR deals with a new feature server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove deprecated QStandardPaths from config fallback chain
5 participants