Browse Source

fixed segfault

master
Robin Thoni 9 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
 #include "yaml-cpp/yaml.h"
2
 #include "yaml-cpp/yaml.h"
3
 #include <QDebug>
3
 #include <QDebug>
4
 #include <QUrlQuery>
4
 #include <QUrlQuery>
5
+#include <QTextCodec>
5
 
6
 
6
 Radio::Radio(QObject *parent) : QObject(parent), logo(0, 0)
7
 Radio::Radio(QObject *parent) : QObject(parent), logo(0, 0)
7
 {
8
 {
105
 void Radio::setCurrentSong(Song *s)
106
 void Radio::setCurrentSong(Song *s)
106
 {
107
 {
107
     if(currentSong != 0)
108
     if(currentSong != 0)
109
+    {
110
+        nextSongs.removeOne(currentSong);
108
         currentSong->deleteLater();
111
         currentSong->deleteLater();
112
+    }
109
     currentSong = s;
113
     currentSong = s;
110
     songTimer->stop();
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
     songTimer->start();
116
     songTimer->start();
115
     nextSongs.removeOne(currentSong);
117
     nextSongs.removeOne(currentSong);
116
     updateNextSongs();
118
     updateNextSongs();
176
 void Radio::songsFinished()
178
 void Radio::songsFinished()
177
 {
179
 {
178
     qDeleteAll(nextSongs);
180
     qDeleteAll(nextSongs);
181
+    nextSongs.clear();
179
     QNetworkReply* reply = (QNetworkReply*)sender();
182
     QNetworkReply* reply = (QNetworkReply*)sender();
180
     YAML::Node itms = YAML::Load(reply->readAll().constData())["itms"];
183
     YAML::Node itms = YAML::Load(reply->readAll().constData())["itms"];
181
     for(unsigned i = 1;i < itms.size(); ++i)
184
     for(unsigned i = 1;i < itms.size(); ++i)

Loading…
Cancel
Save