<div class="gmail_quote">On Mon, Sep 7, 2009 at 8:53 AM, Jean-Baptiste Kempf <span dir="ltr"><<a href="mailto:jb@videolan.org">jb@videolan.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">
> -    int i_type = item->data( 0, TYPE_ROLE ).toInt();<br>
> +    QVariant type = item->data( 0, TYPE_ROLE );<br>
> +    if( type == QVariant() ) return;<br>
> +<br>
> +    int i_type = type.toInt();<br>
</div>Why is that necessary?<br></blockquote><div><br>Because when reacting to single-clicks, the function will be called also for the "Libraries"  item, and that one doesn't have the TYPE_ROLE set, so item->data(0, TYPE_ROLE) will return QVariant(), and doing toInt() on "empty" QVariant will return 0, which will be interpreted as PL_ITEM.<br>
Instead, nothing should happen when clicking (or activating...) the "Libraries" item, which is only a "directory", or a node, if you want...<br><br>Best regards,<br></div></div>