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

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • None
    • None

    Description

      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".

      Attachments

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

        Activity

          People

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

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes