lxqt-panel icon indicating copy to clipboard operation
lxqt-panel copied to clipboard

lxqt-panel 2.2.2 fails to build with C++20

Open Biswa96 opened this issue 5 months ago • 11 comments

Expected Behavior

It should compile with C++20.

Current Behavior

Build fails with the following compiler error.

plugin-statusnotifier/sniasync.h:90:99: error: no type named 'argument_type' in 'std::function<void (ToolTip)>'
   90 |                     finished(qdbus_cast<typename std::function<typename call_signature<F>::type>::argument_type>(reply.value()));
      |                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
plugin-statusnotifier/sniasync.h:85:17: note: while substituting into a lambda expression here
   85 |                 [this, finished, name] (QDBusPendingCallWatcher * call)
      |                 ^
plugin-statusnotifier/statusnotifierbutton.cpp:281:16: note: in instantiation of function template specialization 'SniAsync::propertyGetAsync<(lambda at plugin-statusnotifier/statusnotifierbutton.cpp:281:59)>' requested here
  281 |     interface->propertyGetAsync(QLatin1String("ToolTip"), [this] (ToolTip tooltip) {
      |                ^
Possible Solution

╮( ̄▽ ̄"")╭

Steps to Reproduce (for bugs)
  1. Build with cmake.
Context
System Information
  • LXQt Version: 2.2.0
  • Distribution & Version: Termux
  • Qt Version: 6.9.1
  • liblxqt Version: 2.2.0

Biswa96 avatar Jun 23 '25 05:06 Biswa96

You have lxqt-build-tools 2.2.1 ?

stefonarch avatar Jun 23 '25 06:06 stefonarch

You have lxqt-build-tools 2.2.1 ?

Yes.

Biswa96 avatar Jun 23 '25 06:06 Biswa96

Here it builds fine but I see a lot of warnings warning: array subscript

   inlined from ‘ToolTip StatusNotifierItemAdaptor::toolTip() const’ at /tmp/makepkg/lxqt-panel-git/src/build/plugin-statusnotifier/statusnotifieritemadaptor.cpp:123:66:
/usr/include/c++/15.1.1/bits/move.h:190:11: warning: array subscript 6 is outside array bounds of ‘QVariant [1]’ [-Warray-bounds=]
  190 |       _Tp __old_val = std::move(__obj);

@tsujan ?

stefonarch avatar Jun 23 '25 06:06 stefonarch

I think the -std=c++20 compiler flag is coming from Qt 6.9.1. It is in every AutogenInfo.json and build.ninja files in the build directory of lxqt-panel.

The build issue happens with lxqt-panel 2.2.1 which compiled fine when it was released.

Biswa96 avatar Jun 23 '25 06:06 Biswa96

The standard is set in lxqt-build-tools-2.2.1 (https://github.com/lxqt/lxqt-build-tools/commit/1dc654a8836cc69139342f454f09aadb3da7a1be), and it builds OK for me with Qt 6.10 as well, using gcc-15.1.0

From the full build log at https://github.com/termux/termux-packages/issues/25144 I see it's using clang, building for aarch64.

Wonder if there's something clang-specific going on there?

Chiitoo avatar Jun 23 '25 10:06 Chiitoo

Here building with

export CC=clang
export CXX=clang++

works fine, only some warnings about warning: 'mimeTypes' overrides a member function but is not marked 'override' [-Winconsistent-missing-override] can be seen.

stefonarch avatar Jun 23 '25 10:06 stefonarch

@Biswa96 Check whether you treat warnings as errors when compiling. We know about those warnings: https://github.com/lxqt/lxqt-panel/issues/2253#issuecomment-2950792099

tsujan avatar Jun 23 '25 11:06 tsujan

There in no -Werror and the compiler error is different from that issue. I can not figure out where C++20 is set. Also, std::function::argument_type was removed in C++20.

Biswa96 avatar Jun 23 '25 14:06 Biswa96

Would it be possible to pass the type as a template parameter? Like this diff

--- a/plugin-statusnotifier/sniasync.h
+++ b/plugin-statusnotifier/sniasync.h
@@ -69,7 +69,7 @@ class SniAsync : public QObject
 public:
     SniAsync(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = nullptr);
 
-    template <typename F>
+    template <typename T, typename F>
     inline void propertyGetAsync(QString const &name, F finished)
     {
         static const std::vector<QString> ignored_errors = {
@@ -87,7 +87,7 @@ public:
                     QDBusPendingReply<QVariant> reply = *call;
                     if (reply.isError() && ignored_errors.cend() == std::find(ignored_errors.cbegin(), ignored_errors.cend(), reply.error().name()))
                         qDebug().noquote().nospace() << "Error on DBus request(" << mSni.service() << ',' << mSni.path() << ',' << name << "): " << reply.error();
-                    finished(qdbus_cast<typename std::function<typename call_signature<F>::type>::argument_type>(reply.value()));
+                    finished(qdbus_cast<T>(reply.value()));
                     call->deleteLater();
                 }
         );

with the help of https://stackoverflow.com/a/52556794

Biswa96 avatar Jun 23 '25 16:06 Biswa96

Also, std::function::argument_type was removed in C++20

It was deprecated before C++20. We should do something about it.

tsujan avatar Jun 23 '25 16:06 tsujan

Fixed in #2305

palinek avatar Jun 27 '25 12:06 palinek

Would it be possible to review the pull request please?

Biswa96 avatar Jul 13 '25 04:07 Biswa96