【发布时间】:2010-01-21 08:36:15
【问题描述】:
我遇到了一个复杂的错误。该软件将 PrintParamters 发送到打印机几次。在某个时刻,参数结构的所有 QStrings 都被破坏(坏 ptr)
Structs 中的 QString 是否存在一般问题?
这是我正在使用的结构:
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有一个0x00000000指针
【问题讨论】:
-
你还应该发布代码来展示你是如何使用这个结构的。例如是动态分配的吗?
-
好的,我已经更新了我的帖子
-
根据这些信息有什么想法吗?