Details
-
Bug
-
Resolution: Fixed
-
P3: Somewhat important
-
6.6.2, 6.9.0 FF
-
None
-
Debian testing
-
-
0aad08c6a (dev)
Description
When trying to use lupdate to update translations in a source file that also includes an enum class with the underlying type specified, lupdate fails to recognize the context when using e.g. `tr()` inside of a class method of a class inheriting from QObject and using the Q_OBJECT macro.
Steps to reproduce:
1) Extract attached sample project translation-with-enum-class.zip
2) In the project directory, build the project:
$ ~/development/git/qt5/qtbase/bin/qmake $ make clang++ -c -pipe -g -std=gnu++1z -Wall -Wextra -fPIC -D_REENTRANT -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -I/home/michi/development/git/qt5/qtbase/include -I/home/michi/development/git/qt5/qtbase/include/QtWidgets -I/home/michi/ development/git/qt5/qtbase/include/QtGui -I/home/michi/development/git/qt5/qtbase/include/QtCore -I. -I/home/michi/development/git/qt5/qtbase/mkspecs/linux-clang -o main.o main.cpp /home/michi/development/git/qt5/qtbase/bin/lrelease translation-with-enum-class_de_DE.ts -qm .qm/translation-with-enum-class_de_DE.qm Updating '.qm/translation-with-enum-class_de_DE.qm'... Generated 0 translation(s) (0 finished and 0 unfinished) Ignored 1 untranslated source text(s) /home/michi/development/git/qt5/qtbase/libexec/rcc -name qmake_qmake_qm_files qmake_qmake_qm_files.qrc -o qrc_qmake_qmake_qm_files.cpp clang++ -c -pipe -g -std=gnu++1z -Wall -Wextra -fPIC -D_REENTRANT -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -I/home/michi/development/git/qt5/qtbase/include -I/home/michi/development/git/qt5/qtbase/include/QtWidgets -I/home/michi/ development/git/qt5/qtbase/include/QtGui -I/home/michi/development/git/qt5/qtbase/include/QtCore -I. -I/home/michi/development/git/qt5/qtbase/mkspecs/linux-clang -o qrc_qmake_qmake_qm_files.o qrc_qmake_qmake_qm_files.cpp clang++ -pipe -g -std=gnu++1z -Wall -Wextra -fPIC -dM -E -o moc_predefs.h /home/michi/development/git/qt5/qtbase/mkspecs/features/data/dummy.cpp /home/michi/development/git/qt5/qtbase/libexec/moc -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB --include /tmp/translation-with-enum-class/moc_predefs.h -I/home/michi/development/git/qt5/qtbase/mkspecs/linux-clang -I/tmp/translation-with -enum-class -I/home/michi/development/git/qt5/qtbase/include -I/home/michi/development/git/qt5/qtbase/include/QtWidgets -I/home/michi/development/git/qt5/qtbase/include/QtGui -I/home/michi/development/git/qt5/qtbase/include/QtCore -I/us r/include/c++/14 -I/usr/include/x86_64-linux-gnu/c++/14 -I/usr/include/c++/14/backward -I/usr/lib/gcc/x86_64-linux-gnu/14/include -I/usr/local/include -I/usr/include/x86_64-linux-gnu -I/usr/include MyClass.hxx -o moc_MyClass.cpp clang++ -c -pipe -g -std=gnu++1z -Wall -Wextra -fPIC -D_REENTRANT -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -I/home/michi/development/git/qt5/qtbase/include -I/home/michi/development/git/qt5/qtbase/include/QtWidgets -I/home/michi/ development/git/qt5/qtbase/include/QtGui -I/home/michi/development/git/qt5/qtbase/include/QtCore -I. -I/home/michi/development/git/qt5/qtbase/mkspecs/linux-clang -o moc_MyClass.o moc_MyClass.cpp clang++ -ccc-gcc-name g++ -Wl,-rpath,/home/michi/development/git/qt5/qtbase/lib -Wl,-rpath-link,/home/michi/development/git/qt5/qtbase/lib -o translation-with-enum-class main.o qrc_qmake_qmake_qm_files.o moc_MyClass.o /home/michi/dev elopment/git/qt5/qtbase/lib/libQt6Widgets.so /home/michi/development/git/qt5/qtbase/lib/libQt6Gui.so /home/michi/development/git/qt5/qtbase/lib/libQt6Core.so -lpthread -lGLX -lOpenGL
3) In the project directory, try to update the .ts file using lupdate:
$ ~/development/git/qt5/qtbase/bin/lupdate translation-with-enum-class.pro /tmp/translation-with-enum-class/main.cpp:15: tr() cannot be called without context Updating 'translation-with-enum-class_de_DE.ts'... Found 0 source text(s) (0 new and 0 already existing) Kept 1 obsolete entries
Actual result:
As seen above, the the following warning warning is shown and the .ts file with the German translation is not updated:
/tmp/translation-with-enum-class/main.cpp:15: tr() cannot be called without context
Expected result:
No warning, .ts file should be updated.
Further observations:
1) This works just fine when either removing the
enum class MyEnum : int { FIRST, SECOND, THIRD };
or also when not explicitly specifying the underlying type for the enum class, i.e. using this instead:
enum class MyEnum { FIRST, SECOND, THIRD };
2) Issue is reproducible with both, self-compiled qttools dev as of 213a613244cbbccaaf22f969e73d16052254f593 and lupdate from the qt6-l10n-tools 6.6.2-4 package as provided by Debian testing.
3) The issue is not reproducible when using lupdate from Debian's Qt 5 package instead (qttools5-dev-tools 5.15.13-4):
$ /usr/lib/qt5/bin/lupdate translation-with-enum-class.pro Updating 'translation-with-enum-class_de_DE.ts'... Found 1 source text(s) (1 new and 0 already existing)