[Interest] Can QObject::tr() be used in initialization of static const QString data members? [Qt 5.5.1, Windows]
Phil Weinstein
philw at indra.com
Wed Nov 4 23:54:41 CET 2015
QUESTION: Is there a way to force the initialization of QMetaObject data
to avoid this CRASH in Qt5?
Our large Qt 4.8 application makes use of *Object::tr()* to initialize
static const QString data members. *This is crashing in Qt5* due to
dereferencing a NULL pointer in a QMetaObject.
An abstract example:
class MyClass {
Q_OBJECT
private:
static const QString _MyToolTipText_;
};
In CPP file:
const QString MyClass::_MyToolTipText_ (tr ("It's rude to point"));
In Qt 5.5.1 on Windows, this CRASHES HERE, with _m->d.data_ being NULL:
static inline const char *objectClassName(const QMetaObject *m)
{
return rawStringData(m, priv(m->d.data)->className);
}
Our real stack looks like this, in Visual Studio 2010 (slightly cleaned up):
1. Qt5Cored.dll! objectClassName (const QMetaObject* m) Line 301
2. Qt5Cored.dll! QMetaObject::tr (const char* s, const char* c, int
n) Line 365
3. riverware.exe! DbDmiEditDlg::DatasetModel::tr (const char* s,
const char* c, int n)
4. riverware.exe!`dynamic initializer for
'DbDmiEditDlg::DatasetModel::EditTip''()
5. msvcr100d.dll! _initterm(void (void)* * pfbegin, void (void)* *
pfend) Line 873
6. riverware.exe! __tmainCRTStartup()
7. riverware.exe! WinMainCRTStartup()
8. kernel32.dll! 00000000777f59ed()
9. [Frames below may be incorrect and/or missing, no symbols loaded
for kernel32.dll]
10. ntdll.dll!0000000077a2c541()
Our application is quite huge, and it's going to be very difficult to
have confidence in the completeness changes to myriad uses of
Object::tr() across all our modules. This is a NULL pointer
derefererence, so it's a hard crash, not just an assertion failure. *So
we really are hoping to find* a "centralized" solution, e.g. an explicit
global initialization call.
Thank you in advance,
Phil Weinstein, CADSWES, Colorado, USA
---
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20151104/4a643edf/attachment.html>
More information about the Interest
mailing list