summaryrefslogtreecommitdiff
authorerik <erik>2007-01-31 22:23:27 (UTC)
committer erik <erik>2007-01-31 22:23:27 (UTC)
commit73edac572d9ac9cfd18cc1254fc2019563d55f16 (patch) (unidiff)
treea420b341ce2bcb4a049c76935544b8bce2a0a853
parented5fba8cdb27174427b2e7780508bafa05536ca1 (diff)
downloadopie-73edac572d9ac9cfd18cc1254fc2019563d55f16.zip
opie-73edac572d9ac9cfd18cc1254fc2019563d55f16.tar.gz
opie-73edac572d9ac9cfd18cc1254fc2019563d55f16.tar.bz2
A few files that dereference pointers w/out checking that the pointer is
valid.
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistselection.cpp19
-rw-r--r--noncore/settings/networksettings2/editconnection.cpp5
-rw-r--r--noncore/settings/networksettings2/opietooth2/Opietooth.cpp2
3 files changed, 6 insertions, 20 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,75 +29,62 @@ using namespace Opie::Core;
29/* STD */ 29/* STD */
30#include <stdlib.h> 30#include <stdlib.h>
31 31
32class PlayListSelectionItem : public QListViewItem { 32class PlayListSelectionItem : public QListViewItem {
33public: 33public:
34 PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { 34 PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) {
35 setText( 0, f->name() ); 35 setText( 0, f->name() );
36 setPixmap( 0, f->pixmap() ); 36 setPixmap( 0, f->pixmap() );
37 } 37 }
38 38
39 ~PlayListSelectionItem() { 39 ~PlayListSelectionItem() {
40 }; 40 };
41 41
42 const DocLnk *file() const { return fl; } 42 const DocLnk *file() const { return fl; }
43 43
44private: 44private:
45 const DocLnk *fl; 45 const DocLnk *fl;
46}; 46};
47 47
48 48
49PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) 49PlayListSelection::PlayListSelection( QWidget *parent, const char *name )
50 : QListView( parent, name ) 50 : QListView( parent, name )
51{ 51{
52// odebug << "starting playlistselector" << oendl; 52// odebug << "starting playlistselector" << oendl;
53// #ifdef USE_PLAYLIST_BACKGROUND
54// setStaticBackground( TRUE );
55// setBackgroundPixmap( Resource::loadPixmap( "opieplayer/background" ) );
56
57// setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) );
58// #endif
59// addColumn("Title",236);
60// setAllColumnsShowFocus( TRUE );
61 addColumn( tr( "Playlist Selection" ) ); 53 addColumn( tr( "Playlist Selection" ) );
62 header()->hide(); 54 header()->hide();
63 setSorting( -1, FALSE ); 55 setSorting( -1, FALSE );
64} 56}
65 57
66 58
67PlayListSelection::~PlayListSelection() { 59PlayListSelection::~PlayListSelection() {
68} 60}
69 61
70 62
71// #ifdef USE_PLAYLIST_BACKGROUND
72void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { 63void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) {
73// odebug << "drawBackground" << oendl; 64// odebug << "drawBackground" << oendl;
74 p->fillRect( r, QBrush( white ) ); 65 p->fillRect( r, QBrush( white ) );
75// QImage logo = Resource::loadImage( "launcher/opielogo" );
76// if ( !logo.isNull() )
77// p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo );
78} 66}
79// #endif
80 67
81 68
82void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { 69void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) {
83 if ( event->state() == QMouseEvent::LeftButton ) { 70 if ( event->state() == QMouseEvent::LeftButton ) {
84 QListViewItem *currentItem = selectedItem(); 71 QListViewItem *currentItem = selectedItem();
85 QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); 72 QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) );
86 if ( currentItem && currentItem->itemAbove() == itemUnder ) 73 if ( currentItem && currentItem->itemAbove() == itemUnder )
87 moveSelectedUp(); 74 moveSelectedUp();
88 else if ( currentItem && currentItem->itemBelow() == itemUnder ) 75 else if ( currentItem && currentItem->itemBelow() == itemUnder )
89 moveSelectedDown(); 76 moveSelectedDown();
90 } 77 }
91} 78}
92 79
93 80
94const DocLnk *PlayListSelection::current() { 81const DocLnk *PlayListSelection::current() {
95 PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); 82 PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem();
96 if ( item ) 83 if ( item )
97 return item->file(); 84 return item->file();
98 return NULL; 85 return NULL;
99} 86}
100 87
101 88
102void PlayListSelection::addToSelection( const DocLnk &lnk ) { 89void PlayListSelection::addToSelection( const DocLnk &lnk ) {
103 PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); 90 PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) );
@@ -159,53 +146,51 @@ bool PlayListSelection::first() {
159 if ( item ) 146 if ( item )
160 setSelected( item, TRUE ); 147 setSelected( item, TRUE );
161 else 148 else
162 return FALSE; 149 return FALSE;
163 ensureItemVisible( selectedItem() ); 150 ensureItemVisible( selectedItem() );
164 return TRUE; 151 return TRUE;
165} 152}
166 153
167 154
168bool PlayListSelection::last() { 155bool PlayListSelection::last() {
169 QListViewItem *prevItem = NULL; 156 QListViewItem *prevItem = NULL;
170 QListViewItem *item = firstChild(); 157 QListViewItem *item = firstChild();
171 while ( ( item = item->nextSibling() ) ) 158 while ( ( item = item->nextSibling() ) )
172 prevItem = item; 159 prevItem = item;
173 if ( prevItem ) 160 if ( prevItem )
174 setSelected( prevItem, TRUE ); 161 setSelected( prevItem, TRUE );
175 else 162 else
176 return FALSE; 163 return FALSE;
177 ensureItemVisible( selectedItem() ); 164 ensureItemVisible( selectedItem() );
178 return TRUE; 165 return TRUE;
179} 166}
180 167
181void PlayListSelection::unSelect() 168void PlayListSelection::unSelect()
182{ 169{
183 //QListViewItem *item = selectedItem();
184 setSelected( currentItem(), FALSE); 170 setSelected( currentItem(), FALSE);
185} 171}
186 172
187void PlayListSelection::writeCurrent( Config& cfg ) { 173void PlayListSelection::writeCurrent( Config& cfg ) {
188 cfg.setGroup("PlayList"); 174 cfg.setGroup("PlayList");
189 QListViewItem *item = selectedItem(); 175 QListViewItem *item = selectedItem();
190 if ( item ) 176 if ( item ) {
191 cfg.writeEntry("current", item->text(0) ); 177 cfg.writeEntry("current", item->text(0) );
192 odebug << item->text(0) << oendl; 178 odebug << item->text(0) << oendl;
179 }
193 180
194} 181}
195 182
196void PlayListSelection::setSelectedItem(const QString &strk ) { 183void PlayListSelection::setSelectedItem(const QString &strk ) {
197 184
198 unSelect(); 185 unSelect();
199 QListViewItemIterator it( this ); 186 QListViewItemIterator it( this );
200 for ( ; it.current(); ++it ) { 187 for ( ; it.current(); ++it ) {
201// odebug << it.current()->text(0) << oendl; 188// odebug << it.current()->text(0) << oendl;
202 if( strk == it.current()->text(0)) { 189 if( strk == it.current()->text(0)) {
203// odebug << "We have a match "+strk << oendl; 190// odebug << "We have a match "+strk << oendl;
204 setSelected( it.current(), TRUE); 191 setSelected( it.current(), TRUE);
205 ensureItemVisible( it.current() ); 192 ensureItemVisible( it.current() );
206 return; 193 return;
207 } 194 }
208 } 195 }
209// setSelected( item, TRUE );
210// ensureItemVisible( selectedItem() );
211} 196}
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 ) {
224 NN = (*Mapping)[it]; 224 NN = (*Mapping)[it];
225 if( NN == 0 ) { 225 if( NN == 0 ) {
226 // this item is a controller -> 226 // this item is a controller ->
227 // has radio items as children -> 227 // has radio items as children ->
228 // find selected one 228 // find selected one
229 it = it->firstChild(); 229 it = it->firstChild();
230 Found = 0; 230 Found = 0;
231 while( it ) { 231 while( it ) {
232 if( NNI && it->text(0) == NNI->nodeClass()->name() ) { 232 if( NNI && it->text(0) == NNI->nodeClass()->name() ) {
233 // this radio is part of the collection 233 // this radio is part of the collection
234 ((QCheckListItem *)it)->setOn( 1 ); 234 ((QCheckListItem *)it)->setOn( 1 );
235 updateGUI( it, NNI->nodeClass() ); 235 updateGUI( it, NNI->nodeClass() );
236 // check its children 236 // check its children
237 Found = 1; 237 Found = 1;
238 it = it->firstChild(); 238 it = it->firstChild();
239 NNI = SelectedNodes->next(); 239 NNI = SelectedNodes->next();
240 // do not bother to check other items 240 // do not bother to check other items
241 break; 241 break;
242 } 242 }
243 it = it->nextSibling(); 243 it = it->nextSibling();
244 } 244 }
245 245
246 if( ! Found ) { 246 if( ! Found ) {
247 // this means that this level is NOT present in collection 247 // this means that this level is NOT present in collection
248 // probably INCOMPATIBEL collection OR Missing plugin 248 // probably INCOMPATIBLE collection OR Missing plugin
249 QString pluginName = NNI ? NNI->nodeClass()->name() : "";
249 QMessageBox::warning( 250 QMessageBox::warning(
250 0, 251 0,
251 tr( "Error presentig NetworkSetup" ), 252 tr( "Error presentig NetworkSetup" ),
252 tr( "<p>Old NetworkSetup or missing plugin \"<i>%1</i>\"</p>" ). 253 tr( "<p>Old NetworkSetup or missing plugin \"<i>%1</i>\"</p>" ).
253 arg(NNI->nodeClass()->name()) ); 254 arg(pluginName) );
254 return; 255 return;
255 } 256 }
256 257
257 // it now contains selected radio 258 // it now contains selected radio
258 NN = (*Mapping)[it]; 259 NN = (*Mapping)[it];
259 } else { 260 } else {
260 // automatic selection 261 // automatic selection
261 if( NNI == 0 || it->text(0) != NNI->nodeClass()->name() ) { 262 if( NNI == 0 || it->text(0) != NNI->nodeClass()->name() ) {
262 // should exist and be the same 263 // should exist and be the same
263 if( NNI ) { 264 if( NNI ) {
264 QMessageBox::warning( 265 QMessageBox::warning(
265 0, 266 0,
266 tr( "Error presentig NetworkSetup" ), 267 tr( "Error presentig NetworkSetup" ),
267 tr( "<p>Old NetworkSetup or missing plugin \"<i>%1</i>\"</p>" ). 268 tr( "<p>Old NetworkSetup or missing plugin \"<i>%1</i>\"</p>" ).
268 arg(NNI->nodeClass()->name()) ); 269 arg(NNI->nodeClass()->name()) );
269 } else { 270 } else {
270 QMessageBox::warning( 271 QMessageBox::warning(
271 0, 272 0,
272 tr( "Error presentig NetworkSetup" ), 273 tr( "Error presentig NetworkSetup" ),
273 tr( "<p>Missing NetworkSetup\"<i>%1</i>\"</p>" ). 274 tr( "<p>Missing NetworkSetup\"<i>%1</i>\"</p>" ).
274 arg(it->text(0)) ); 275 arg(it->text(0)) );
275 } 276 }
276 return; 277 return;
277 } 278 }
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 ) :
423} 423}
424 424
425OTScan::~OTScan() { 425OTScan::~OTScan() {
426 if( MyIcons ) 426 if( MyIcons )
427 delete Icons; 427 delete Icons;
428 OTGateway::releaseOTGateway(); 428 OTGateway::releaseOTGateway();
429 429
430 // send all peers that we do not care about states 430 // send all peers that we do not care about states
431 QListViewItem * Lit = DetectedPeers_LV->firstChild(); 431 QListViewItem * Lit = DetectedPeers_LV->firstChild();
432 while( Lit ) { 432 while( Lit ) {
433 ((PeerLVI *)Lit)->peer()->stopFindingOutState( ); 433 ((PeerLVI *)Lit)->peer()->stopFindingOutState( );
434 Lit = Lit->nextSibling(); 434 Lit = Lit->nextSibling();
435 } 435 }
436} 436}
437 437
438// static scan dialog function 438// static scan dialog function
439int OTScan::getDevice( OTPeer *& Peer, 439int OTScan::getDevice( OTPeer *& Peer,
440 int & Channel, 440 int & Channel,
441 OTGateway * OT, 441 OTGateway * OT,
442 const UUIDVector & Filter, 442 const UUIDVector & Filter,
443 QWidget* Parent ) { 443 QWidget* Parent ) {
444 bool IsUp = 0; 444 bool IsUp = 0;
445 unsigned int i; 445 unsigned int i;
446 446
447 if( ! OT->isEnabled() ) { 447 if( ! OT || ! OT->isEnabled() ) {
448 QMessageBox::warning( 0, 448 QMessageBox::warning( 0,
449 tr("Scanning problem"), 449 tr("Scanning problem"),
450 tr("Bluetooth not enabled" ) 450 tr("Bluetooth not enabled" )
451 ); 451 );
452 return QDialog::Rejected; 452 return QDialog::Rejected;
453 } 453 }
454 454
455 // check if bluetooth is up 455 // check if bluetooth is up
456 OTDriverList & DL = OT->getDriverList(); 456 OTDriverList & DL = OT->getDriverList();
457 for( i = 0; 457 for( i = 0;
458 i < DL.count(); 458 i < DL.count();
459 i ++ ) { 459 i ++ ) {
460 if( DL[i]->isUp() ) { 460 if( DL[i]->isUp() ) {
461 // one device that is up found 461 // one device that is up found
462 IsUp = 1; 462 IsUp = 1;
463 break; 463 break;
464 } 464 }
465 } 465 }
466 466
467 // use this driver 467 // use this driver
468 OT->setScanWith( OT->driver(i) ); 468 OT->setScanWith( OT->driver(i) );
469 469
470 // create dialog 470 // create dialog
471 QDialog * Dlg = new QDialog( Parent, 0, TRUE ); 471 QDialog * Dlg = new QDialog( Parent, 0, TRUE );