[Qt-interest] QList::size() returns negetive and append() crashes
Neel Basu
neel.basu.z at gmail.com
Thu Mar 12 18:04:46 CET 2009
Here goes my Code
QList::size() returns negative
and QLIst::append() crashes
------------------------------------------------------------------------------------------------
class Protocol : public QObject{
friend class ProtocolExecutioner;
Q_OBJECT
private:
QList< ProtocolSegment* > segments;
public:
Protocol(QObject *parent = 0);
~Protocol();
public:
int addSegment(ProtocolSegment* p);
void insertSegment(ProtocolSegment* p, int pos);
ProtocolSegment* removeSegment(int pos);
ProtocolSegment* segmentAt(int pos) const;
int count() const;
};
.....
int Protocol::addSegment(ProtocolSegment* p){
int id = segments.size();
qDebug() << id;//prints -15248256
segments.append(p);//crashes saying "QList: Out of memory"
return id;
}
-------------------------------------------------
segments.append(p); appends an element to a list
Now what makes my code Crash
Thanks
Neel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090312/c6c17ec2/attachment.html
More information about the Qt-interest-old
mailing list