Hi,

I have encountered problem with lupdate. It is not able to add few strings to translation file.
Simplified code sample is showed below.

TrProblem.pro
Qt Code:
  1. TARGET = TrProblem
  2. TEMPLATE = app
  3.  
  4. TRANSLATIONS = TrProblem_de.ts
  5.  
  6. DEFINES += EV_SOURCE
  7.  
  8. SOURCES += main.cpp\
  9. mainwindow.cpp
  10.  
  11. HEADERS += mainwindow.h \
  12. ../common/defs.h
  13.  
  14. FORMS += mainwindow.ui
To copy to clipboard, switch view to plain text mode 

defs.h
Qt Code:
  1. #ifndef _DEFS_H_
  2. #define _DEFS_H_
  3.  
  4. enum some_enum_t
  5. {
  6. SOME_VALUE_0 = 0,
  7. SOME_VALUE_1,
  8. SOME_VALUE_2,
  9. SOME_VALUE_3
  10. };
  11.  
  12. #ifdef EV_SOURCE
  13.  
  14. #include <QCoreApplication>
  15.  
  16. class CommonStr
  17. {
  18. Q_DECLARE_TR_FUNCTIONS(CommonStr)
  19.  
  20. public:
  21. static CommonStr& Acquire() { static CommonStr str; return str; }
  22.  
  23. QString to_str(some_enum_t pt);
  24.  
  25. private:
  26. CommonStr() {};
  27. };
  28.  
  29.  
  30. #define RETURN_TYPE QString
  31. #define ACCESS_OBJECT
  32. #define TR(STRING) tr(STRING)
  33.  
  34. #else
  35.  
  36. #define ACCESS_OBJECT
  37. #define RETURN_TYPE char const *
  38. #define TR(STRING) STRING
  39.  
  40. #endif
  41.  
  42. inline RETURN_TYPE ACCESS_OBJECT to_str(product_t pt)
  43. {
  44. switch(pt)
  45. {
  46. case SOME_VALUE_0: return TR("SOME_VALUE_0");
  47. case SOME_VALUE_1: return TR("SOME_VALUE_1");
  48. case SOME_VALUE_2: return TR("SOME_VALUE_2");
  49. case SOME_VALUE_3: return TR("SOME_VALUE_3");
  50. default: return TR("UNKNOWN_VALUE");
  51. }
  52. }
  53.  
  54.  
  55.  
  56. #endif
To copy to clipboard, switch view to plain text mode 

mainwindow.cpp - CommomStr usage
Qt Code:
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3.  
  4. #include "defs.h"
  5.  
  6. MainWindow::MainWindow(QWidget *parent) :
  7. QMainWindow(parent),
  8. ui(new Ui::MainWindow)
  9. {
  10. ui->setupUi(this);
  11. QString str = CommonStr::Acquire().to_str(SOME_VALUE_1);
  12. str;
  13. }
  14.  
  15. MainWindow::~MainWindow()
  16. {
  17. delete ui;
  18. }
To copy to clipboard, switch view to plain text mode 


After running command "lupdate -verbose TrProblem.pro" i receive such output:
/usr/include/qt4/QtCore/qstringbuilder.h:45: circular inclusion of /usr/include/qt4/QtCore/qstring.h

/usr/include/qt4/QtGui/qwmatrix.h:45: circular inclusion of /usr/include/qt4/QtGui/qmatrix.h

/usr/include/qt4/QtGui/qactiongroup.h:45: circular inclusion of /usr/include/qt4/QtGui/qaction.h

/home/kuba/Develop/translation_problem/common/defs.h:46: tr() cannot be called without context

/home/kuba/Develop/translation_problem/common/defs.h:47: tr() cannot be called without context

/home/kuba/Develop/translation_problem/common/defs.h:48: tr() cannot be called without context

/home/kuba/Develop/translation_problem/common/defs.h:49: tr() cannot be called without context

/home/kuba/Develop/translation_problem/common/defs.h:50: tr() cannot be called without context

Updating 'TrProblem_de.ts'...
Found 1 source text(s) (0 new and 1 already existing)
Is there any problem with such macro definitions for lupdate? I know that tr() function does not work with #defines but if it expands defs.h correctly it should work in my opinion.