Qt程序运行时出现Error - RtlWerpReportException failed with status code :-1073741823. Will try to launch the process directly原因总结
####### Qt程序在运行时出现了上述错误,并且我的程序出现了数据错乱的情况,百度后说是因为内存原因,段错误,仔细查看了自己的代码并没有发现 指针变量未初始化的情况。
####### 通过调试得出原因:QNetworkManager类
,在使用时,可能在同一时间段内QNetworkRequest
的attribute被两个对象同时设定和使用,导致出现数据错乱,数据无法正常取出的情况!
####### 解决办法: 重新建立QNetworkManager
分别针对不同的对象,这样它们attribute的使用区域不会重叠
我编写这个函数的部分代码如下:
// 请求开始
void Request::get(void *attribute, QUrl url)
{
QNetworkRequest request(url);
request.setAttribute(QNetworkRequest::Attribute(QNetworkRequest::User + 1), QVariant::fromValue(attribute));
this->get(request);
}
// 请求完成
QVariant attribute = request.attribute(QNetworkRequest::Attribute(QNetworkRequest::User + 1));
if(attribute.isNull())
{
emit dataRequested(receivedData);
}
else
{
void * attributePointer = attribute.value<void *>();
emit dataRequested(attributePointer, receivedData);
}
// 出错位置
// attribute首先在这里被占用
void *widgetAttribute = (void *)homeMovieItem;
this->homeImgRequest->get(widgetAttribute, QUrl(homeItem->imgPath));
connect(this->imgRequest, SIGNAL(dataRequested(void*,QByteArray)), this, SLOT(onReceivedItemImg(void*,QByteArray)));
// 这里attribute再次被占用
void *widgetAttribute = (void *)actressWidgetItem;
this->actressImgRequest->get(widgetAttribute, QUrl(actressItem->imgPath));
connect(this->imgRequest, SIGNAL(dataRequested(void*,QByteArray)), this, SLOT(onReceivedActressImg(void*,QByteArray)));