I have timer to emit signal to trigger sendMessage every 30 millisecond. after hours , i got heap corruptions
it said
Windows has triggered a breakpoint in matx_migrate.exe.
This may be due to a corruption of the heap, and indicates a bug in
matx_migrate.exe or any of the DLLs it has loaded.
The output window may have more diagnostic information
void ClientThread::sendMessage(){
#ifdef _DEBUG
qWarning
("sendMessage %d\n",
QThread::currentThreadId());
#endif
numOfMsg++;
if(numOfMsg>CHECK_PERIOD){
sendCheckMessage();
numOfMsg=0;
}
QList<QByteArray> dataToSend= cannonPtr->getDataToSend();
if(!dataToSend.isEmpty()){
out << (quint16)0;//reserve for size
out << (quint16)dataToSend.count();
for(int i=0; i<dataToSend.count(); i++){
data.append(dataToSend[i]);
//out<<dataToSend[i];
}
out.device()->seek(0);
out<< (quint16)(data.size() - sizeof(quint16));
#ifdef _DEBUG
quint16 size;
quint16 num;
quint16 kind;
qint32 frame;
qint32 id;
qint32 x;
qint32 y;
bool dead;
out.device()->seek(0);
out>>size>>num>>kind>>frame>>id>>x>>y>>dead>>time;
qWarning()<<"size: "<<size<<"num: "<<num<<"frame: "<<frame;
#endif
socketPrt->write(data);
socketPrt->waitForBytesWritten();
dataToSend.clear();
}
}
void ClientThread::sendMessage(){
#ifdef _DEBUG
qWarning("sendMessage %d\n", QThread::currentThreadId());
#endif
numOfMsg++;
if(numOfMsg>CHECK_PERIOD){
sendCheckMessage();
numOfMsg=0;
}
QList<QByteArray> dataToSend= cannonPtr->getDataToSend();
if(!dataToSend.isEmpty()){
QByteArray data;
QDataStream out( &data, QIODevice::ReadWrite );
out.setVersion(QDataStream::Qt_4_4);
out << (quint16)0;//reserve for size
out << (quint16)dataToSend.count();
for(int i=0; i<dataToSend.count(); i++){
data.append(dataToSend[i]);
//out<<dataToSend[i];
}
out.device()->seek(0);
out<< (quint16)(data.size() - sizeof(quint16));
#ifdef _DEBUG
quint16 size;
quint16 num;
quint16 kind;
qint32 frame;
qint32 id;
qint32 x;
qint32 y;
bool dead;
QTime time;
out.device()->seek(0);
out>>size>>num>>kind>>frame>>id>>x>>y>>dead>>time;
qWarning()<<"size: "<<size<<"num: "<<num<<"frame: "<<frame;
#endif
socketPrt->write(data);
socketPrt->waitForBytesWritten();
dataToSend.clear();
}
}
To copy to clipboard, switch view to plain text mode
any comments thanks very much
Bookmarks