使用QT出大问题了!!!

Qicoico Qicoico 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
ASSERT failure in QVector<T>::at: "index out of range"
我用了一个线程等待消息,等到消息后,放入QStringList,然后打印。以下是该线程函数的代码:

while(1)
{
ERROR_NO perr = ERR_UNKNOWN;
uint32 msgItem = portMessageQPend(gLocalUpdateUpdateStatusMsgQ, 0, &perr);
if (ERR_SUCCESS == perr)
{
mutex.lock();
LOCAL_UPDATE_MSG_ITEM item = *((LOCAL_UPDATE_MSG_ITEM*)&msgItem);
MEM_HANDLE hData = item.msg_data;
int dataLen = mem_len(hData);
unsigned char *buf = new unsigned char[dataLen];
mem_read(buf, dataLen, hData, 0, dataLen);
mem_free(hData);

if (item.msg_type == UPDATE_DATA_INFO)
{
char updateBuf[256] = {0};
char temp_buf[10];
for(int i = 0; i < dataLen; i++)
{
sprintf_s(temp_buf,10,"%02x,",buf[i]);
strcat(updateBuf, temp_buf);
}

strList.append(QString::fromLocal8Bit(updateBuf));
}
else
{
strList.append(QString::fromLocal8Bit((const char*)buf));
}

int count = strList.count();
if(count > 20)
strList.erase(strList.begin());
strModel.setStringList(strList);

delete[] buf;
mutex.unlock();
}

}

望各位大侠给个解决方案啊!
...全文
评论 18
收藏 已收藏
分享
返回顶部
Qicoico
Qt 21,503 成员 26,693 内容