author | erik <erik> | 2007-01-31 22:23:27 (UTC) |
---|---|---|
committer | erik <erik> | 2007-01-31 22:23:27 (UTC) |
commit | 73edac572d9ac9cfd18cc1254fc2019563d55f16 (patch) (side-by-side diff) | |
tree | a420b341ce2bcb4a049c76935544b8bce2a0a853 | |
parent | ed5fba8cdb27174427b2e7780508bafa05536ca1 (diff) | |
download | opie-73edac572d9ac9cfd18cc1254fc2019563d55f16.zip opie-73edac572d9ac9cfd18cc1254fc2019563d55f16.tar.gz opie-73edac572d9ac9cfd18cc1254fc2019563d55f16.tar.bz2 |
A few files that dereference pointers w/out checking that the pointer is
valid.
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistselection.cpp | 35 | ||||
-rw-r--r-- | noncore/settings/networksettings2/editconnection.cpp | 5 | ||||
-rw-r--r-- | noncore/settings/networksettings2/opietooth2/Opietooth.cpp | 2 |
3 files changed, 14 insertions, 28 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistselection.cpp b/noncore/multimedia/opieplayer2/playlistselection.cpp index 678ebdf..780d705 100644 --- a/noncore/multimedia/opieplayer2/playlistselection.cpp +++ b/noncore/multimedia/opieplayer2/playlistselection.cpp @@ -29,183 +29,168 @@ using namespace Opie::Core; /* STD */ #include <stdlib.h> class PlayListSelectionItem : public QListViewItem { public: PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { setText( 0, f->name() ); setPixmap( 0, f->pixmap() ); } ~PlayListSelectionItem() { }; const DocLnk *file() const { return fl; } private: const DocLnk *fl; }; PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) : QListView( parent, name ) { // odebug << "starting playlistselector" << oendl; -// #ifdef USE_PLAYLIST_BACKGROUND -// setStaticBackground( TRUE ); -// setBackgroundPixmap( Resource::loadPixmap( "opieplayer/background" ) ); - -// setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) ); -// #endif -// addColumn("Title",236); -// setAllColumnsShowFocus( TRUE ); addColumn( tr( "Playlist Selection" ) ); header()->hide(); setSorting( -1, FALSE ); } PlayListSelection::~PlayListSelection() { } -// #ifdef USE_PLAYLIST_BACKGROUND void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { // odebug << "drawBackground" << oendl; p->fillRect( r, QBrush( white ) ); -// QImage logo = Resource::loadImage( "launcher/opielogo" ); -// if ( !logo.isNull() ) -// p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); } -// #endif void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { if ( event->state() == QMouseEvent::LeftButton ) { QListViewItem *currentItem = selectedItem(); QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); if ( currentItem && currentItem->itemAbove() == itemUnder ) moveSelectedUp(); else if ( currentItem && currentItem->itemBelow() == itemUnder ) moveSelectedDown(); } } const DocLnk *PlayListSelection::current() { PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); if ( item ) - return item->file(); + return item->file(); return NULL; } void PlayListSelection::addToSelection( const DocLnk &lnk ) { PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); QListViewItem *current = selectedItem(); if ( current ) item->moveItem( current ); setSelected( item, TRUE ); ensureItemVisible( selectedItem() ); } void PlayListSelection::removeSelected() { QListViewItem *item = selectedItem(); delete item; setSelected( currentItem(), TRUE ); ensureItemVisible( selectedItem() ); } void PlayListSelection::moveSelectedUp() { QListViewItem *item = selectedItem(); if ( item && item->itemAbove() ) - item->itemAbove()->moveItem( item ); + item->itemAbove()->moveItem( item ); ensureItemVisible( selectedItem() ); } void PlayListSelection::moveSelectedDown() { QListViewItem *item = selectedItem(); if ( item && item->itemBelow() ) item->moveItem( item->itemBelow() ); ensureItemVisible( selectedItem() ); } bool PlayListSelection::prev() { QListViewItem *item = selectedItem(); if ( item && item->itemAbove() ) setSelected( item->itemAbove(), TRUE ); else - return FALSE; + return FALSE; ensureItemVisible( selectedItem() ); return TRUE; } bool PlayListSelection::next() { QListViewItem *item = selectedItem(); if ( item && item->itemBelow() ) setSelected( item->itemBelow(), TRUE ); else - return FALSE; + return FALSE; ensureItemVisible( selectedItem() ); return TRUE; } bool PlayListSelection::first() { QListViewItem *item = firstChild(); if ( item ) setSelected( item, TRUE ); else - return FALSE; + return FALSE; ensureItemVisible( selectedItem() ); return TRUE; } bool PlayListSelection::last() { QListViewItem *prevItem = NULL; QListViewItem *item = firstChild(); while ( ( item = item->nextSibling() ) ) - prevItem = item; + prevItem = item; if ( prevItem ) setSelected( prevItem, TRUE ); else - return FALSE; + return FALSE; ensureItemVisible( selectedItem() ); return TRUE; } void PlayListSelection::unSelect() { - //QListViewItem *item = selectedItem(); setSelected( currentItem(), FALSE); } void PlayListSelection::writeCurrent( Config& cfg ) { cfg.setGroup("PlayList"); QListViewItem *item = selectedItem(); - if ( item ) + if ( item ) { cfg.writeEntry("current", item->text(0) ); - odebug << item->text(0) << oendl; + odebug << item->text(0) << oendl; + } } void PlayListSelection::setSelectedItem(const QString &strk ) { unSelect(); QListViewItemIterator it( this ); for ( ; it.current(); ++it ) { // odebug << it.current()->text(0) << oendl; if( strk == it.current()->text(0)) { // odebug << "We have a match "+strk << oendl; setSelected( it.current(), TRUE); ensureItemVisible( it.current() ); return; } } -// setSelected( item, TRUE ); -// ensureItemVisible( selectedItem() ); } diff --git a/noncore/settings/networksettings2/editconnection.cpp b/noncore/settings/networksettings2/editconnection.cpp index a9bef65..d948fb9 100644 --- a/noncore/settings/networksettings2/editconnection.cpp +++ b/noncore/settings/networksettings2/editconnection.cpp @@ -224,54 +224,55 @@ void EditNetworkSetup::setNetworkSetup( NetworkSetup * NC ) { NN = (*Mapping)[it]; if( NN == 0 ) { // this item is a controller -> // has radio items as children -> // find selected one it = it->firstChild(); Found = 0; while( it ) { if( NNI && it->text(0) == NNI->nodeClass()->name() ) { // this radio is part of the collection ((QCheckListItem *)it)->setOn( 1 ); updateGUI( it, NNI->nodeClass() ); // check its children Found = 1; it = it->firstChild(); NNI = SelectedNodes->next(); // do not bother to check other items break; } it = it->nextSibling(); } if( ! Found ) { // this means that this level is NOT present in collection - // probably INCOMPATIBEL collection OR Missing plugin + // probably INCOMPATIBLE collection OR Missing plugin + QString pluginName = NNI ? NNI->nodeClass()->name() : ""; QMessageBox::warning( 0, tr( "Error presentig NetworkSetup" ), tr( "<p>Old NetworkSetup or missing plugin \"<i>%1</i>\"</p>" ). - arg(NNI->nodeClass()->name()) ); + arg(pluginName) ); return; } // it now contains selected radio NN = (*Mapping)[it]; } else { // automatic selection if( NNI == 0 || it->text(0) != NNI->nodeClass()->name() ) { // should exist and be the same if( NNI ) { QMessageBox::warning( 0, tr( "Error presentig NetworkSetup" ), tr( "<p>Old NetworkSetup or missing plugin \"<i>%1</i>\"</p>" ). arg(NNI->nodeClass()->name()) ); } else { QMessageBox::warning( 0, tr( "Error presentig NetworkSetup" ), tr( "<p>Missing NetworkSetup\"<i>%1</i>\"</p>" ). arg(it->text(0)) ); } return; } diff --git a/noncore/settings/networksettings2/opietooth2/Opietooth.cpp b/noncore/settings/networksettings2/opietooth2/Opietooth.cpp index fc30bf8..e23fc9c 100644 --- a/noncore/settings/networksettings2/opietooth2/Opietooth.cpp +++ b/noncore/settings/networksettings2/opietooth2/Opietooth.cpp @@ -423,49 +423,49 @@ OTScan::OTScan( QWidget * parent, OTIcons * _IC ) : } OTScan::~OTScan() { if( MyIcons ) delete Icons; OTGateway::releaseOTGateway(); // send all peers that we do not care about states QListViewItem * Lit = DetectedPeers_LV->firstChild(); while( Lit ) { ((PeerLVI *)Lit)->peer()->stopFindingOutState( ); Lit = Lit->nextSibling(); } } // static scan dialog function int OTScan::getDevice( OTPeer *& Peer, int & Channel, OTGateway * OT, const UUIDVector & Filter, QWidget* Parent ) { bool IsUp = 0; unsigned int i; - if( ! OT->isEnabled() ) { + if( ! OT || ! OT->isEnabled() ) { QMessageBox::warning( 0, tr("Scanning problem"), tr("Bluetooth not enabled" ) ); return QDialog::Rejected; } // check if bluetooth is up OTDriverList & DL = OT->getDriverList(); for( i = 0; i < DL.count(); i ++ ) { if( DL[i]->isUp() ) { // one device that is up found IsUp = 1; break; } } // use this driver OT->setScanWith( OT->driver(i) ); // create dialog QDialog * Dlg = new QDialog( Parent, 0, TRUE ); |