我有一个复杂的错误。该软件将PrintParamters发送给打印机几次。在某个时刻,参数结构的所有QStrings都被破坏(坏ptr)为什么QString在struct中有时是bad-ptr?
Structs中是否存在QStrings的一般问题?
这里是我使用的结构:
typedef struct RecorderPrintParam {
ES_DataType xxxxxxxxxx;
bool xxxxxxxxxxx;
bool xxxxxxxxxxxx;
bool xxxxxxxxxxxx;
int xxxxxxxxxxxxxxxxxxxxxx;
double xxxxxxxxxxxxxxx;
double xxxxxxxxxx;
bool xxxxxxxxxxx;
int xxxxxxxxxxxxxxx;
double xxxxxxxxxxx;
bool xxxxxxxxxxx;
bool xxxxxxxxxx;
double xxxxxxxxx;
QString xname;
QString yname;
QString anotherValue;
QString opername;
QString region;
QString application;
QString version;
AxisUnit axUnit ;
double axLenM;
double xxxxxxxx;
double xxxxxxxx;
int xxxxxxxx;
double xxxxxxxxx;
double xxxxxxxxx;
bool xxxxxxxxxxxxxxx;/
double xxxxxxxxxxxxxxx;
double xxxxxxxxxx;
bool xxxxxxxxx;
}RecorderPrintParam;
这里是如何的结构是使用: 从GUI级称为:
void
MyDlg::UpdateRecorderPrintParameters()
{
RecorderPrintParam param;
....
....
param.xname = QString("abc def 123");
_recorder->setParam(¶m);
}
param.xname已经有一个不好ascii ptr! ? 我也尝试使用just =“abc def 123”而不是= QString(“abc def 123”);但它的出现同样的错误
这是通过setParam职能的样子:
RecorderInterface::setParam(RecorderPrintParam *up)
{
....
...
if(up->xname.compare(_myParams.xname)!=0) _newHeaderPrint=true;
...
...
}
}
的XName仍具有在那一刻“8xname = {d = 0x08e2d568}”的地址,但xname.ascii有一个00000000指针
您还应该发布显示您如何使用此结构的代码。例如它是动态分配的吗? – Alon 2010-01-21 08:39:43
好的,我更新了我的帖子 – Christoferw 2010-01-21 08:51:18
基于这些信息的任何想法? – Christoferw 2010-01-21 09:15:47