Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-42744 lupdate needs C++11 support
  3. QTBUG-42166

lupdate is confused by C++11 lambdas in constructor initializer lists

    XMLWordPrintable

Details

    • Technical task
    • Resolution: Done
    • P2: Important
    • 5.6.1
    • Tools: Linguist
    • None
    • Win7, Qt 32-bit, OpenGL, Visual Studio 2012

    • 4ea581c95ae9704b250591c5d4d9b0517f5b62f2

    Description

      If I use a lambda in a constructor initializer list (not a C++ initializer list, like in QTBUG-34128), I get an error message "tr() cannot be called without context". I suspect this and QTBUG-34128 are a problem in lupdate's tokenizer routine looking for a "{" to start the constructor as the context but finding a brace when it didn't expect it.

      Sample code:

      // MyWidget inherits from QWidget
      MyWidget::MyWidget( QWidget* parent )
          : QWidget( parent )
          , _callback( []{ std::cout << "Hi\n"; } )  // Note the lambda
          , _translated1( tr( "Howdy" ) ) // "tr() cannot be called without context"
      {
          _translated2 = tr( "Hey" );     // "tr() cannot be called without context"
      }
      

      Both of the tr calls here will generate messages from lupdate.

      Attachments

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

        Activity

          People

            dg0yt Kai Pastor
            mlimber mlimber
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes