[Qt-interest] QList::size() returns negetive and append() crashes

Neel Basu neel.basu.z at gmail.com
Fri Mar 13 16:03:38 CET 2009


On Friday 13 March 2009 03:55:16 Denis Dzyubenko wrote:
> Neel Basu wrote:
> > 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
>
> that shouldn't be happening. Are you sure that the object of type
> Protocol has been created? It sounds like it could be that the object is
> either not yet created or already deleted. If that is on Linux or Mac,
> could you run your application through valgrind or debugger to check for
> that?

Thanks
I forgot to construct the object.
I just invoked methods from Object Pointer without invoking new

Thanks
Neel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090313/e37197f9/attachment.html 


More information about the Qt-interest-old mailing list