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

[Building/Packaging] Remaining warnings by Qt6 and C++20 #1046

Open
1 of 6 tasks
Vekhir opened this issue Aug 14, 2024 · 3 comments
Open
1 of 6 tasks

[Building/Packaging] Remaining warnings by Qt6 and C++20 #1046

Vekhir opened this issue Aug 14, 2024 · 3 comments

Comments

@Vekhir
Copy link
Contributor

Vekhir commented Aug 14, 2024

Describe the problem
The PR #1001 removed many warnings that were cluttering the build logs while improving compatibility and potentially preempting future refactorings.
However, not all warnings were removed because they are trickier and might involve larger code changes. This issue shall provide a platform to collect and categorise these warnings and work towards a solution for them.
At the time of writing, 6 warnings remain.

Versions
Current dev (e9abc43)

Build commands
I'm using the cmake community build for Arch Linux, though qmake should be similarly affected. Full instructions: PKGBUILD

Warnings

1. SingleApplication: QCryptographicHash::addData is deprecated
/build/openboard-git/src/OpenBoard/src/singleapplication/singleapplication_p.cpp: In member function ‘void SingleApplicationPrivate::genBlockServerName()’:
/build/openboard-git/src/OpenBoard/src/singleapplication/singleapplication_p.cpp:134:20: warning: ‘void QCryptographicHash::addData(const char*, qsizetype)’ is deprecated: Use the QByteArrayView overload instead [-Wdeprecated-declarations]
  134 |     appData.addData( "SingleApplication", 17 );
      |     ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/qt6/QtCore/QCryptographicHash:1,
                 from /build/openboard-git/src/OpenBoard/src/singleapplication/singleapplication_p.cpp:40:
/usr/include/qt6/QtCore/qcryptographichash.h:79:10: note: declared here
   79 |     void addData(const char *data, qsizetype length);
      |          ^~~~~~~
2. UBPreferencesController.cpp: implicit capture of ‘this’ via ‘[=]’ is deprecated in C++20
/build/openboard-git/src/OpenBoard/src/core/UBPreferencesController.cpp: In lambda function:
/build/openboard-git/src/OpenBoard/src/core/UBPreferencesController.cpp:189:150: warning: implicit capture of ‘this’ via ‘[=]’ is deprecated in C++20 [-Wdeprecated]
  189 |     connect(mPreferencesUI->keyboardPaletteKeyButtonSize, qOverload<int>(&QComboBox::currentIndexChanged), settings->boardKeyboardPaletteKeyBtnSize, [=](int index) {
      |                                                                                                                                                      ^
/build/openboard-git/src/OpenBoard/src/core/UBPreferencesController.cpp:189:150: note: add explicit ‘this’ or ‘*this’ capture
3. UBPersistenceManager.cpp: implicit capture of ‘this’ via ‘[=]’ is deprecated in C++20
/build/openboard-git/src/OpenBoard/src/core/UBPersistenceManager.cpp: In lambda function:
/build/openboard-git/src/OpenBoard/src/core/UBPersistenceManager.cpp:192:105: warning: implicit capture of ‘this’ via ‘[=]’ is deprecated in C++20 [-Wdeprecated]
  192 |     std::function<std::shared_ptr<UBDocumentProxy> (QFileInfo contentInfo)> createDocumentProxyLambda = [=](QFileInfo contentInfo) {
      |                                                                                                         ^
/build/openboard-git/src/OpenBoard/src/core/UBPersistenceManager.cpp:192:105: note: add explicit ‘this’ or ‘*this’ capture
4. UBMainWindow.cpp: constexpr QKeyCombination operator+ is deprecated
/build/openboard-git/src/OpenBoard/src/gui/UBMainWindow.cpp: In constructor ‘UBMainWindow::UBMainWindow(QWidget*, Qt::WindowFlags)’:
/build/openboard-git/src/OpenBoard/src/gui/UBMainWindow.cpp:77:56: warning: ‘constexpr QKeyCombination operator+(Qt::Modifier, Qt::Key)’ is deprecated: Use operator| instead [-Wdeprecated-declarations]
   77 |     actionQuit->setShortcut(QKeySequence(Qt::ALT + Qt::Key_F4));
      |                                                        ^~~~~~
In file included from /usr/include/qt6/QtCore/qobjectdefs.h:12,
                 from /usr/include/qt6/QtCore/qobject.h:10,
                 from /usr/include/qt6/QtCore/qabstractanimation.h:7,
                 from /usr/include/qt6/QtCore/QtCore:15,
                 from /usr/include/qt6/QtGui/QtGuiDepends:3,
                 from /usr/include/qt6/QtGui/QtGui:3,
                 from /build/openboard-git/src/OpenBoard/src/gui/UBMainWindow.cpp:30:
/usr/include/qt6/QtCore/qnamespace.h:1965:27: note: declared here
 1965 | constexpr QKeyCombination operator+(Qt::Modifier modifier, Qt::Key key) noexcept
      |                           ^~~~~~~~
5. UBNetworkAccessManager.cpp: ‘++’ expression of ‘volatile’-qualified type is deprecated
/build/openboard-git/src/OpenBoard/src/network/UBNetworkAccessManager.cpp: In member function ‘void UBNetworkAccessManager::proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)’:
/build/openboard-git/src/OpenBoard/src/network/UBNetworkAccessManager.cpp:136:5: warning: ‘++’ expression of ‘volatile’-qualified type is deprecated [-Wvolatile]
  136 |     mProxyAuthenticationCount++;
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~
6. web/simplebrowser/tabwidget.cpp: addAction overload is deprecated
/build/openboard-git/src/OpenBoard/src/web/simplebrowser/tabwidget.cpp: In member function ‘void TabWidget::handleContextMenuRequested(const QPoint&)’:
/build/openboard-git/src/OpenBoard/src/web/simplebrowser/tabwidget.cpp:123:19: warning: ‘typename std::enable_if<((! std::is_same<const char*, Func1>::value) && QtPrivate::IsPointerToTypeDerivedFromQObject<T*>::Value), QAction*>::type QMenu::addAction(const QString&, const Obj*, Func1, const QKeySequence&) [with Obj = TabWidget; Func1 = WebView* (TabWidget::*)(); typename std::enable_if<((! std::is_same<const char*, Func1>::value) && QtPrivate::IsPointerToTypeDerivedFromQObject<T*>::Value), QAction*>::type = QAction*]’ is deprecated: Use addAction(text, shortcut, object, slot) instead. [-Wdeprecated-declarations]
  123 |     menu.addAction(tr("New &Tab"), this, &TabWidget::createTab, QKeySequence::AddTab);
      |     ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/qt6/QtWidgets/QMenu:1,
                 from /build/openboard-git/src/OpenBoard/src/web/simplebrowser/tabwidget.cpp:55:
/usr/include/qt6/QtWidgets/qmenu.h:78:9: note: declared here
   78 |         addAction(const QString &text, const Obj *object, Func1 slot,
      |         ^~~~~~~~~

Progress

Warning 1 needs a dependency update. For the other warnings, there is a PR for further discussion.

@letsfindaway What do you think of warnings 4 and 6 in particular? Are there better solutions?

-- Vekhir

@Vekhir
Copy link
Contributor Author

Vekhir commented Aug 14, 2024

For 2, 3, and 5, the solutions in the respective PRs are good.
For 4 and 6, I'd like a second opinion whether my approach is good practice.
I don't know enough about the dependency update necessary for 1 to make a PR for that.

@letsfindaway
Copy link
Collaborator

For 4 and 6, I'd like a second opinion whether my approach is good practice.

In both cases I would support your proposals.

For topic 4, using | instead of + for combining a modifier with a key is not actively promoted and not really documented for Qt 5.15. However the defined and documented values for keys and modifiers make sure that there is no difference in the result. So I do not see a reason why we should not use | for all Qt versions.

For topic 6: With Qt 6.3 the addAction functions have been pulled up from the QMenu to QWidget, where some simple overloads already existed. At the same time the signature was modified to be more logical (define the key sequence first and then the receiver). I have no doubt that the function is identical, as the documentation for both are also nearly identical, see Qt5.15 QMenu::addAction() and Qt 6.5 QWidget::addAction(). However we need the #if as there is no common signature for all versions.

@Vekhir
Copy link
Contributor Author

Vekhir commented Aug 16, 2024

Thanks. I've made PRs to that effect in #1051 and #1049

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

No branches or pull requests

2 participants