I try to make a M3U file(playlist) but when I try to write a file my program crash without an error.
bool Playlist::savePlaylist(QString path)
{
this->filename = path;
QFile file(path);
if((file.open(QIODevice::WriteOnly | QIODevice::Truncate)) == false)
{
return false;
}
QTextStream out(&file);
if(out.status() != QTextStream::Ok)
{
return false;
}
out << "#EXTM3U" << endl;
for(int i = 0 ; i < this->getSize() ; i++)
{
SongInfo si = this->songs.at(i);
int durata = this->getLengthInSeconds(si.getAddress().toString(QUrl::None));
out << "#EXTINF:" << durata << "," << ID3_GetArtist(&si.getTag()) << " - "
<< ID3_GetTitle(&si.getTag()) << endl;
out << si.getAddress().toString(QUrl::None) << endl;
}
file.close();
return true;
}
If I try with 188 files, 1.07 Gb size on disc, after about 100 songs the program crash. When I try to get the SongInfo at that position I get the crash. If I try with let's say 30-40 songs everything works perfect. I don't know what could be the problem. I've tried to write chunks, and delete those chunks from memory, I've used flush. I don't know what to do, where the problem could be. If I write to console those information(a for loop just for printing) everything is perfect, but when I try to write...crash.
What could be the problem?