Browse Source

fixed segfault

master
Robin Thoni 8 years ago
parent
commit
b890ce5a5f
1 changed files with 6 additions and 3 deletions
  1. 6
    3
      radio.cpp

+ 6
- 3
radio.cpp View File

@@ -2,6 +2,7 @@
2 2
 #include "yaml-cpp/yaml.h"
3 3
 #include <QDebug>
4 4
 #include <QUrlQuery>
5
+#include <QTextCodec>
5 6
 
6 7
 Radio::Radio(QObject *parent) : QObject(parent), logo(0, 0)
7 8
 {
@@ -105,12 +106,13 @@ void Radio::setCoverBase(QUrl u)
105 106
 void Radio::setCurrentSong(Song *s)
106 107
 {
107 108
     if(currentSong != 0)
109
+    {
110
+        nextSongs.removeOne(currentSong);
108 111
         currentSong->deleteLater();
112
+    }
109 113
     currentSong = s;
110 114
     songTimer->stop();
111
-    if(s->getDuration() < 0)
112
-        qDebug()<<s->getDuration()<<name;
113
-    songTimer->setInterval(s->getDuration());
115
+    songTimer->setInterval(s->getDuration() <= 0 ? 1000 : s->getDuration());
114 116
     songTimer->start();
115 117
     nextSongs.removeOne(currentSong);
116 118
     updateNextSongs();
@@ -176,6 +178,7 @@ void Radio::logoError(QNetworkReply::NetworkError)
176 178
 void Radio::songsFinished()
177 179
 {
178 180
     qDeleteAll(nextSongs);
181
+    nextSongs.clear();
179 182
     QNetworkReply* reply = (QNetworkReply*)sender();
180 183
     YAML::Node itms = YAML::Load(reply->readAll().constData())["itms"];
181 184
     for(unsigned i = 1;i < itms.size(); ++i)

Loading…
Cancel
Save