author | llornkcor <llornkcor> | 2002-10-10 01:20:36 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-10-10 01:20:36 (UTC) |
commit | 2cbc91d6aff15c931426f3c835b5126c7da3ba2b (patch) (side-by-side diff) | |
tree | 65d6cf3c96306ccbb55c44c5d21af3777835b134 | |
parent | 41aaa97e19b29f96fced9013a707cc6d16bc2143 (diff) | |
download | opie-2cbc91d6aff15c931426f3c835b5126c7da3ba2b.zip opie-2cbc91d6aff15c931426f3c835b5126c7da3ba2b.tar.gz opie-2cbc91d6aff15c931426f3c835b5126c7da3ba2b.tar.bz2 |
other crash fixes
-rw-r--r-- | noncore/multimedia/opieplayer2/om3u.cpp | 29 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 64 |
2 files changed, 47 insertions, 46 deletions
diff --git a/noncore/multimedia/opieplayer2/om3u.cpp b/noncore/multimedia/opieplayer2/om3u.cpp index 0be727b..039f3b1 100644 --- a/noncore/multimedia/opieplayer2/om3u.cpp +++ b/noncore/multimedia/opieplayer2/om3u.cpp @@ -51,13 +51,7 @@ Om3u::Om3u( const QString &filePath, int mode) : QStringList (){ -//filePath is path name to m3u //qDebug("<<<<<<<new m3u "+filePath); - f.setName(filePath); -// if(f.exists()) -// f.open( IO_ReadWrite); -// else -// f.open( IO_ReadWrite | IO_Truncate); - f.open(mode); - + f.setName(filePath); + f.open(mode); } @@ -132,10 +126,12 @@ void Om3u::readPls() { //it's a pls file void Om3u::write() { //writes list to m3u file - QString list; + QString list; + if(count()>0) { for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { - qDebug(*it); - list += *it+"\n"; + qDebug(*it); + list += *it+"\n"; } f.writeBlock( list, list.length() ); + } // f.close(); } @@ -146,14 +142,15 @@ void Om3u::add(const QString &filePath) { //adds to m3u file void Om3u::remove(const QString &filePath) { //removes from m3u list - QString list, currentFile; + QString list, currentFile; + if(count()>0) { for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { - currentFile=*it; -// qDebug(*it); + currentFile=*it; + // qDebug(*it); - if( filePath != currentFile) + if( filePath != currentFile) list += currentFile+"\n"; } f.writeBlock( list, list.length() ); - + } } diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index e28efd0..f9192e8 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp @@ -186,11 +186,11 @@ void PlayListWidget::writeDefaultPlaylist() { QString currentString = config.readEntry( "CurrentPlaylist", filename); if( currentString == filename) { - Om3u *m3uList; -// qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); + Om3u *m3uList; + // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); + if( d->selectedFiles->first() ) { m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); - d->selectedFiles->first(); do { -// qDebug(d->selectedFiles->current()->file()); - m3uList->add( d->selectedFiles->current()->file() ); + // qDebug(d->selectedFiles->current()->file()); + m3uList->add( d->selectedFiles->current()->file() ); } while ( d->selectedFiles->next() ); @@ -199,4 +199,6 @@ void PlayListWidget::writeDefaultPlaylist() { m3uList->close(); if(m3uList) delete m3uList; + + } } } @@ -854,7 +856,9 @@ void PlayListWidget::writeCurrentM3u() { QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); + if( d->selectedFiles->first()) { Om3u *m3uList; m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); - d->selectedFiles->first(); + + qDebug( d->selectedFiles->current()->file()); do { @@ -868,4 +872,5 @@ void PlayListWidget::writeCurrentM3u() { if(m3uList) delete m3uList; + } } @@ -891,38 +896,37 @@ void PlayListWidget::writem3u() { } + if( d->selectedFiles->first()) { m3uList = new Om3u(filename, IO_ReadWrite); - - d->selectedFiles->first(); - do { + do { m3uList->add( d->selectedFiles->current()->file()); - } - while ( d->selectedFiles->next() ); -// qDebug( list ); - m3uList->write(); - m3uList->close(); - if(m3uList) delete m3uList; + } + while ( d->selectedFiles->next() ); + // qDebug( list ); + m3uList->write(); + m3uList->close(); + if(m3uList) delete m3uList; - if(fileDlg) delete fileDlg; + if(fileDlg) delete fileDlg; - DocLnk lnk; - lnk.setFile( filename); - lnk.setIcon("opieplayer2/playlist2"); - lnk.setName( name); //sets file name + DocLnk lnk; + lnk.setFile( filename); + lnk.setIcon("opieplayer2/playlist2"); + lnk.setName( name); //sets file name -// qDebug(filename); - Config config( "OpiePlayer" ); - config.setGroup( "PlayList" ); + // qDebug(filename); + Config config( "OpiePlayer" ); + config.setGroup( "PlayList" ); - config.writeEntry("CurrentPlaylist",filename); - currentPlayList=filename; + config.writeEntry("CurrentPlaylist",filename); + currentPlayList=filename; - if(!lnk.writeLink()) { - qDebug("Writing doclink did not work"); - } + if(!lnk.writeLink()) { + qDebug("Writing doclink did not work"); + } - setCaption(tr("OpiePlayer: ") + name); + setCaption(tr("OpiePlayer: ") + name); + } } - } |