[Qt-interest] Application crashing on Win32/Qt4.4.3
Tony Rietwyk
tony.rietwyk at rightsoft.com.au
Tue Feb 17 00:56:28 CET 2009
Vladimir wrote:
> I have a set of globally defined QString's:
>
> 23 /* TODO: translations */
> 24 const QString NObject::keyNumber =
> QString(tr("Object Number"));
> 25 const QString NObject::keyType =
> QString(tr("Type"));
> 26 const QString NObject::keySize =
> QString(tr("Size"));
> 27 const QString NObject::keyRelatedPosition =
> QString(tr("Related Position"));
> 28 const QString NObject::keyMovable =
> QString(tr("Movable"));
> 29 const QString NObject::keyCombustionLevel =
> QString(tr("Combustion"));
> 30 const QString NObject::keyTemperature =
> QString(tr("Temperature"));
> 31 const QString NObject::keyEnergyConsumption =
> QString(tr("Energy-release"));
>
> that are later added into a QStringList:
>
> 34 const QStringList CellField::viewports(QStringList()
> 35 << QString(tr("Cell Number"))
> 36 << nuclear::NObject::keyNumber
> 37 << nuclear::NObject::keyCombustionLevel
> 38 << nuclear::NObject::keyTemperature
> 39 << nuclear::NObject::keyEnergyConsumption);
>
> It works ok in linux, but crashes on windows with:
<snip>
> ../Qt/4.4.3/include/QtCore/../../src/
> corelib/tools/qstringlist.h:82 #5 0x0041068b in
> __static_initialization_and_destruction_0(int, int)
> ( __initialize_p=1, __priority=65535) at src/ui/cellfield.cc:39 #6
Hi Vladimir,
I'm not sure about Mac or Linux, but on Windows with Visual Studio, you
cannot assume the order of initialisation of any global objects. In this
case, the strings may not have been initialised yet.
In my case, I call a routine from main to do these.
Also, the tr() function will probably not work until you have created the
QApplication / QCoreApplication - so you will need to do the translations
later as well.
Hope that helps,
Tony Rietwyk
More information about the Qt-interest-old
mailing list