[vlc-devel] commit: Qt4: store input_item_t* in plitem and handle metadata in model ( Ilkka Ollakka )

Rémi Denis-Courmont remi at remlab.net
Fri Aug 14 12:50:46 CEST 2009


On Fri, 14 Aug 2009 12:19:47 +0200, Jakob Leben <jakob.leben at gmail.com>
wrote:
> However, now I think of a possible solution: even if both parent and it's
> children are being removed, they shouldn't be just freed, but their
> internal
> pointers (parent -> children, child -> parent) should still be adjusted.
> This way when control in a qt interface returns from a view to our
> implementation of a model's function and it uses a QModelIndex with a
> pointer to the parent item, both that pointer and it's internal pointer
to
> children are valid (only the pointer to children is NULL). This way we
can
> still serve the view's request for data about the parent, even if it
> changed
> since it obtained the QModelIndex. I guess qt views should be
> (cosmetically)
> protected against this change of data, since the documentation states
that
> QModelIndex is only temporary. The main concern is just to prevent
> segmentation faults.

It's not just segmentation fault. Reading data while another thread may be
modifying it is not defined.

There are a few separate issues:
* The structure of the playlist is protected by the playlist lock (we may
want to convert it to a read-write lock). This covers accessing
parent/children pointers of playlist items.
* The life-time of individual playlist items could be managed by reference
counting. Currently, they live until the end of the playlist.
* The internal data of each playlist item could be protected by an
individual lock (or R/W lock). Currently, it is protected by the playlist
lock.

In other words, holding a reference to an object allows you to *lock* it.
In turn, locking an object allows you to read and write its content.

-- 
Rémi Denis-Courmont




More information about the vlc-devel mailing list