Hi folks!
Recently I've upgraded my developing environment. Namely, I've moved from Qt 4.8.4 and MSVC 2010 to Qt 5.3.1 and MSVC 2013. The problem I've faced is that my application crashes on launch, and stack trace proves that the crash happens during the initialization of some static class fields.
See the following example:
// header file
class MyClass : QObject
Q_OBJECT
public:
...
private:
static const QString CLASS_NAME;
// *.cpp file
const QString MyClass::CLASS_NAME = MyClass::tr("FOO"); // crash when calling tr()
const QString MyClass::CLASS_NAME = QObject::tr("FOO"); // but this works normally
During debugging into Qt I've found that the MyClass::tr()
method eventually calls QMetaObject::tr()
and it appears that all the fields of the QMetaObject
instance are NULL
. The crash then occurs when referencing some of them.
Notable fact is that the crash is not reproduced on another machine with Ubuntu 14.04 and Qt 5.2.1.
Surely, I could just replace the MyClass
name to the QObject
one, but my project consists of 63 libraries so I'm afraid of possible translation conficts.