lupdate error: Qualifying with unknown namespace/class

Viewed 5457

I ran into a very peculiar error using lupdate v4.7.2. I got the error message

module/foo.cpp:6: Qualifying with unknown namespace/class ::foo

for a couple of classes in a project with about 50 classes. I boiled the problem down to a simple example:

src/project.pro:

QT       += core
TARGET = test
TEMPLATE = app

SOURCES += main.cpp \
           screen.cpp

HEADERS += screen.h

TRANSLATIONS += de.ts

src/module/foo.h:

namespace sp {
class foo {
    initWidgets();
};
} // namespace sp

src/module/foo.cpp:

#include <QString>
#include "module/foo.h"

namespace sp {
    foo::initWidgets() {
    QString bar = tr("bar");
}
} // namespace sp

main.cpp has an empty main function in it.

The code compiles (barring any copypasta mistakes I might have produced here), so the syntax is basically correct.

7 Answers

This error occurs also if the tr()-macro is placed in too deeply nested subfolders.

E.g., in the following example, the command lupdate -noobsolete . -ts ts/* error message reads pwd/a/b/c/c.cpp:5: Qualifying with unknown namespace/class ::C.

QT       += core gui

SOURCES += \
    main.cpp \
    a/a.cpp \
    a/b/b.cpp \
    a/b/c/c.cpp

HEADERS += \
    a/a.h \
    a/b/b.h \
    a/b/c/c.h

TRANSLATIONS += \
    ts/foo.ts

However, as others have already mentioned, the *.ts-file seems to be updated correctly.

Some forward declarations seem to cause this warning too. Removing the 'template class MutexQList' line in this class example solves the issue in my case:

#include "bufferwriter.h"
#include "resampleworker.h"
#include "worker_help.h"

class Buffer;
class Project;

template <class T> class MutexQList;

class WorkerRegistry : public QObject
{
    Q_OBJECT
private:
    static WorkerRegistry *my_instance;

    MutexQList<BufferWriter *>*bw_list;                 ///< Liste mit registrierten BufferWriter Instanzen
    MutexQList<ResampleWorker *>*rw_list;               ///< Liste mit registrierten ResampleWorker Instanzen

public:
    static WorkerRegistry *instance();
    static WorkerRegistry &ref();
    static void destroy();
}
Related