Assert in trying to acces an item in a QList "Index out of bounds" - Possible fix, but might not be correct.

Tim Beaulen tbscope at gmail.com
Sun Dec 2 12:30:24 UTC 2007


[13:21] <tbscope> I have a bug fix, but I'm not sure if it's the correct
fix. I'll explain:
[13:21] <tbscope> I want to open a shoutcast playlist (pls file) but Amarok
crashes
[13:21] <tbscope> Assert in some QList "index out of bounds"
[13:22] <tbscope> I searched for the problem and found that at some point,
the list with added tracks becomes empty
[13:22] <tbscope> The culprit is PlaylistModel.cpp -> Model::insertOptioned
[13:22] <tbscope> In that function there's a check to see if the added track
is a playlist
[13:23] <tbscope> obviously it is
[13:23] <tbscope> so, the playlisthandler loads the playlist and takes
(read: removes) the track from the list
[13:23] <tbscope> but the function continues
[13:23] <tbscope> resulting in trying to add an empty list
[13:23] <tbscope> thus resulting in an out of bounds error somewhere later
[13:24] <hurra> tbscope: if noone responds here, write an email to the
amarok mailinglist :)
[13:24] <tbscope> Adding a check to see if the list becomes empty and
returning from Model::insertOptioned seems to solve that problem
[13:24] <tbscope> hurra: thanks, I'll do that
[13:24] <nhnFreespirit> tbscope: we are talking Amarok2 here?
[13:24] <tbscope> nhnFreespirit: yes, the version in trunk
[13:26] <nhnFreespirit> tbscope: hmmm... adding an empty list really should
not cause a crash. If you send a patch to the mailing list I will have a
look at it! :-)

Patch:

Index: PlaylistModel.cpp
===================================================================
--- PlaylistModel.cpp (revision 743903)
+++ PlaylistModel.cpp (working copy)
@@ -509,6 +509,8 @@
}
}

+ if (list.isEmpty())
+ return;

int firstItemAdded = -1;
if( options & Replace )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/amarok/attachments/20071202/ee7e2a97/attachment.html>


More information about the Amarok mailing list