Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-29726

clazy-connect-3arg-lambda warning shouldn't show for lambdas with no captures

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Out of scope
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • None

      I have the following code:

      ```

      QObject::connect(aboutAction, &QAction::triggered, []()

      {     QMessageBox msg;     msg.setIconPixmap(QPixmap(":/icon.ico"));     msg.setWindowIcon(QIcon(":/icon.ico"));     msg.setWindowTitle(QObject::tr("About"));     msg.setText(QObject::tr("About my program"));     msg.exec(); }

      );

      ```

       

      This code gives me a clazy-connect-3arg-lambda warning, even though the lambda takes no captures, so obviously there can't be a receiving object.

       

      According to https://github.com/KDE/clazy/blob/1.11/docs/checks/README-connect-3arg-lambda.md this warning "is only shown if the lambda body dereferences at least one QObject other than the sender". But in this case the QObject in question is created inside the lambda. So I suggest that this condition should be changed to "is only shown if the lambda body dereferences at least one QObject that has been captured".

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            iamsergio Sergio Martins
            donaldduck Donald Duck
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes