From 2cbc91d6aff15c931426f3c835b5126c7da3ba2b Mon Sep 17 00:00:00 2001 From: llornkcor Date: Thu, 10 Oct 2002 01:20:36 +0000 Subject: other crash fixes --- (limited to 'noncore/multimedia/opieplayer2') 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 @@ -50,15 +50,9 @@ Om3u::Om3u( const QString &filePath, int mode) : QStringList (){ -//filePath is path name to m3u //qDebug("<<<<<<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(); } @@ -145,16 +141,17 @@ 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() ); - + } } void Om3u::deleteFile(const QString &filePath) {//deletes m3u file 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 @@ -185,19 +185,21 @@ void PlayListWidget::writeDefaultPlaylist() { QString filename=QPEApplication::documentDir() + "/default.m3u"; QString currentString = config.readEntry( "CurrentPlaylist", filename); if( currentString == filename) { - Om3u *m3uList; -// qDebug("<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>"); + Om3u *m3uList; + // qDebug("<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>"); + 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() ); m3uList->write(); m3uList->close(); if(m3uList) delete m3uList; + + } } } @@ -853,9 +855,11 @@ void PlayListWidget::writeCurrentM3u() { cfg.setGroup("PlayList"); 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 { qDebug( d->selectedFiles->current()->file()); @@ -867,6 +871,7 @@ void PlayListWidget::writeCurrentM3u() { m3uList->close(); if(m3uList) delete m3uList; + } } /* @@ -890,40 +895,39 @@ void PlayListWidget::writem3u() { filename = QPEApplication::documentDir() + "/" +name+".m3u"; } + 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); + } } - } void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { -- cgit v0.9.0.2