SIGSEGV Segmentation fault while loading QMediaPlaylist

  • I am currently working on a music player.

    At one point, I save an m3u playlist file:
    @moodPlaylist->save(QUrl::fromLocalFile(QFileInfo("moods/" + moodName + ".m3u").absoluteFilePath()), "m3u");@
    This works flawlessly. The m3u file is created. The line is bound to a button.

    I then show the filenames in a QListWidget. On the clicked() slot, I try to load a playlist:
    @currentMoodPlaylist->load(QUrl::fromLocalFile(QFileInfo("moods/" + ui->moodList->currentItem()->text() + ".m3u").absoluteFilePath(), "m3u");@
    Because of this line, I get the Segmentation fault.

    I understand that I try to access memory that somehow doesn't belong to my app. However, I don't quite understand where the problem is in my case...

  • Hi,

    How can one find out what's wrong looking at a line like
    QFileInfo("moods/" + ui->moodList->currentItem()->text() + ".m3u").absoluteFilePath()

    So many pointers!

    To debug such issues, first break this chain of calls. Assign each value to a variable. Find out which one causes the segfault. If you don't understand the reason this way then create a project that reproduces your issue and upload it somewhere. Post the link here.

  • Thanks for your reply. I just did what you suggested:

    @QString playlistName = ui->moodList->currentItem()->text();
    QString playlistPath = QFileInfo("moods/" + playlistName + ".m3u").absoluteFilePath();
    currentMoodPlaylist->load(QUrl::fromLocalFile(playlistPath), "m3u");

    The seg fault is still caused by the load() line.

    However as it turns out, it doesn't even matter what I do, as soon as I reference the currentMoodPlaylist, I get a seg fault. For example I tried:
    (No pointers this time ;)). Same error. It is set like that in my mainwindow.h:
    QMediaPlaylist *currentMoodPlaylist;@

  • What do you mean by "set"? I just see a pointer there. Don't you instantiate a QMediaPlaylist object somewhere in your project, preferably in the constructor of the containing object?

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.