Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-140548

[Reg 6.9.1->6.9.2] Different misdetection of correct namespace/class with tr

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P2: Important P2: Important
    • None
    • 6.9.2
    • Tools: Linguist
    • None
    • fbaba6941 (18.0)

      Unfortunately lupdate now misdetects the context wrt namespace differently than it did in Qt 6.9.2

      In Qt Creator we use one "Tr" struct per plugin to consolidate all translations/tr-calls from that plugin. The struct is always called "Tr", has the "Q_DECLARE_TR_FUNCTIONS" macro and lives in the plugin namespace. E.g.

      https://code.qt.io/cgit/qt-creator/qt-creator.git/tree/src/plugins/coreplugin/coreplugintr.h
      https://code.qt.io/cgit/qt-creator/qt-creator.git/tree/src/plugins/cppeditor/cppeditortr.h

      Normally we only use the "Tr" struct from that plugin, but sometimes a plugin uses a translation from a different plugin, e.g. some project management plugins use some common translations from the ProjectExplorer plugin.

      With Qt 6.9.2 the following situation fails to correctly determine the correct translation context/namespace:

      #include "cppeditortr.h"
      
      #include <coreplugin/coreplugintr.h>
      
      using namespace Core;
      
      namespace CppEditor::Internal {
      ...
          Tr::tr("this should be CppEditor::Tr")
      ...
          ::Core::Tr::tr("this is Core::Tr")
      ...
      } // namespace CppEditor::Internal
      

      In this case the plain Tr::tr should be resolved as CppEditor::Tr::tr, but the translations is wrongly assigned to the Core::Tr context.

      Qt 6.9.1 still works. I guess this was an unnoticed side-effect of the fix for QTBUG-136768

        For Gerrit Dashboard: QTBUG-140548
        # Subject Branch Project Status CR V

            kkohne Kai Köhne
            con Eike Ziller
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes