I was beaten by a segmentation fault,
following is my source code
void PieceThread::slotReadReady()
{
while(reply!=NULL&&!pauseFlag&&!reply->atEnd())
{
file->seek(workingPos);
workingPos+=file->write(reply->read(4096)); //segmentation fault happend here!
emit this->signalProgressIncrease(workingPos-oldWorkingPos);
oldWorkingPos=workingPos;
}
}
void PieceThread::slotReadReady()
{
while(reply!=NULL&&!pauseFlag&&!reply->atEnd())
{
QMutexLocker locker(&mutex);
file->seek(workingPos);
workingPos+=file->write(reply->read(4096)); //segmentation fault happend here!
emit this->signalProgressIncrease(workingPos-oldWorkingPos);
oldWorkingPos=workingPos;
}
}
To copy to clipboard, switch view to plain text mode
I promise that the "file" and the "reply" are legal pointer,
following is the Call Stack Window
0 QList<QNetworkReplyImplPrivate::InternalNotificati ons>::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 //here is the "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:
laceMetaCall 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
the line 0's call stack source code is from "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) //segmentation fault happend here
return QBool(true);
return QBool(false);
}
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) //segmentation fault happend here
return QBool(true);
return QBool(false);
}
To copy to clipboard, switch view to plain text mode

thank you for helping me!
Bookmarks