Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. SIGSEGV Segmentation fault while loading QMediaPlaylist

SIGSEGV Segmentation fault while loading QMediaPlaylist

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Hombrus
    wrote on last edited by
    #1

    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...

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ckakman
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • H Offline
        H Offline
        Hombrus
        wrote on last edited by
        #3

        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:
        @currentMoodPlaylist->clear();@
        (No pointers this time ;)). Same error. It is set like that in my mainwindow.h:
        @private:
        QMediaPlaylist *currentMoodPlaylist;@

        1 Reply Last reply
        0
        • C Offline
          C Offline
          ckakman
          wrote on last edited by
          #4

          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?

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved