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
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
2 participants