[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    Re: strange bug with QList
From:       David Faure <david () mandrakesoft ! com>
Date:       2001-06-22 9:54:45
[Download RAW message or body]

On Friday 22 June 2001 12:48, Igor Janssen wrote:
> hi all
> KIllu often crashes when it working with lists
> For example:
> ---------
> QList<GObject> selected;
> .....
> QListIterator<GObject> i(selected);
> ++i
> ....
> ---------
> It crashes at different places(on constructor or later)
> for constructor:
> ---------
> #4  0x4097db89 in QGList::append () from /usr/lib/qt/lib/libqt.so.2
> #5  0x4097ea23 in QGListIterator::QGListIterator ()
>    from /usr/lib/qt/lib/libqt.so.2
> ---------
> Anybody know about same problems?

This can happen if you are iterating over a temporary QList, for instance
QList<GObject> objects() { return m_objects; }
[...]
QListIterator<GObject>( thatClass->objects() );
....

This creates an iterator over a temporary object -> bad.
The fix is obviously to change it into a reference:
const QList<GObject> & objects() { return m_objects; }

-- 
David FAURE, david@mandrakesoft.com, faure@kde.org
http://perso.mandrakesoft.com/~david/, http://www.konqueror.org/
KDE, Making The Future of Computing Available Today
_______________________________________________
Koffice-devel mailing list
Koffice-devel@master.kde.org
http://master.kde.org/mailman/listinfo/koffice-devel

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic