这是
出错的源代码
- void PieceThread::slotReadReady()
- {
- while(reply!=NULL&&!pauseFlag&&!reply->atEnd())
- {
- QMutexLocker locker(&mutex);
- file->seek(workingPos);
- workingPos+=file->write(reply->read(4096));//这个就是出错的行,从堆栈调用来看,错在这个read
- emit this->signalProgressIncrease(workingPos-oldWorkingPos);
- oldWorkingPos=workingPos;
- }
- }
小弟在局部变量中查看了,可以向大家保证的是 file和reply都是合法的指针。
程序是在运行一段时间出错,或者不出错。
这里是
错误堆栈:
0 QList<QNetworkReplyImplPrivate::InternalNotifications>::contains qlist.h 864 0x680cd407
1 QNetworkReplyImplPrivate::backendNotify qnetworkreplyimpl.cpp 365 0x68048179
2 QNetworkReplyImpl::readData qnetworkreplyimpl.cpp 873 0x6804a2f8
3 QIODevice::read qiodevice.cpp 829 0x6a1ab817
4 QIODevice::read qiodevice.cpp 964 0x6a1abd3b //这里应该是那个read(4096)了吧
5 PieceThread::slotReadReady piecethread.cpp 48 0x4048e3
6 PieceThread::qt_metacall moc_piecethread.cpp 84 0x408a73
7 QMetaObject::metacall qmetaobject.cpp 237 0x6a2060b0
8 QMetaCallEvent::placeMetaCall qobject.cpp 535 0x6a210d55
9 QObject::event qobject.cpp 1217 0x6a212c60
10 QApplicationPrivate::notify_helper qapplication.cpp 4462 0x7ebde0
11 QApplication::notify qapplication.cpp 3862 0x7e9732
12 QCoreApplication::notifyInternal qcoreapplication.cpp 731 0x6a2015f8
13 QCoreApplication::sendEvent qcoreapplication.h 215 0x6a268308
14 QCoreApplicationPrivate::sendPostedEvents qcoreapplication.cpp 1372 0x6a2026a3
15 qt_internal_proc qeventdispatcher_win.cpp 497 0x6a22499f
16 USER32!GetDC C:\WINDOWS\system32\user32.dll 0 0x77d18734
17 ?? 0 0x3301a4
18 ?? 0 0x401
19 ?? 0
第0行的那个堆栈调用函数在下面,是在qlist.h中定义的
- Q_OUTOFLINE_TEMPLATE QBool QList<T>::contains(const T &t) const
- {
- Node *b = reinterpret_cast<Node *>(p.begin());
- Node *i = reinterpret_cast<Node *>(p.end());
- while (i-- != b)
- if (i->t() == t) //这就是出错位置吧
- return QBool(true);
- return QBool(false);
- }
这个
问题困扰我真的很久了,谢谢大家帮忙啊!
[ 此帖被83888788在2011-03-15 20:28重新编辑 ]