summaryrefslogtreecommitdiff
authordrw <drw>2003-03-15 16:09:22 (UTC)
committer drw <drw>2003-03-15 16:09:22 (UTC)
commit69823b154b29cd62c9d53f7ebdaae4cb7dd61939 (patch) (unidiff)
treef678ad4bb0cf7005ce00e7231713372220c75cf6
parentede78d4ab60d2c78427c4b1cc51cd9accc0aed1c (diff)
downloadopie-69823b154b29cd62c9d53f7ebdaae4cb7dd61939.zip
opie-69823b154b29cd62c9d53f7ebdaae4cb7dd61939.tar.gz
opie-69823b154b29cd62c9d53f7ebdaae4cb7dd61939.tar.bz2
Added several checks to ensure we have a valid server or destination. Fixes bug #727, and also prevents several other segfault situations.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/settingsimpl.cpp114
1 files changed, 72 insertions, 42 deletions
diff --git a/noncore/settings/aqpkg/settingsimpl.cpp b/noncore/settings/aqpkg/settingsimpl.cpp
index 9f611da..e2afada 100644
--- a/noncore/settings/aqpkg/settingsimpl.cpp
+++ b/noncore/settings/aqpkg/settingsimpl.cpp
@@ -286,10 +286,20 @@ void SettingsImpl :: editServer( int sel )
286{ 286{
287 currentSelectedServer = sel; 287 currentSelectedServer = sel;
288 Server *s = dataMgr->getServer( servers->currentText() ); 288 Server *s = dataMgr->getServer( servers->currentText() );
289 serverName = s->getServerName(); 289 if ( s )
290 servername->setText( s->getServerName() ); 290 {
291 serverurl->setText( s->getServerUrl() ); 291 serverName = s->getServerName();
292 active->setChecked( s->isServerActive() ); 292 servername->setText( s->getServerName() );
293 serverurl->setText( s->getServerUrl() );
294 active->setChecked( s->isServerActive() );
295 }
296 else
297 {
298 serverName = "";
299 servername->setText( "" );
300 serverurl->setText( "" );
301 active->setChecked( false );
302 }
293} 303}
294 304
295void SettingsImpl :: newServer() 305void SettingsImpl :: newServer()
@@ -305,8 +315,11 @@ void SettingsImpl :: removeServer()
305{ 315{
306 changed = true; 316 changed = true;
307 Server *s = dataMgr->getServer( servers->currentText() ); 317 Server *s = dataMgr->getServer( servers->currentText() );
308 dataMgr->getServerList().removeRef( s ); 318 if ( s )
309 servers->removeItem( currentSelectedServer ); 319 {
320 dataMgr->getServerList().removeRef( s );
321 servers->removeItem( currentSelectedServer );
322 }
310} 323}
311 324
312void SettingsImpl :: changeServerDetails() 325void SettingsImpl :: changeServerDetails()
@@ -332,21 +345,22 @@ void SettingsImpl :: changeServerDetails()
332 if ( !newserver ) 345 if ( !newserver )
333 { 346 {
334 Server *s = dataMgr->getServer( servers->currentText() ); 347 Server *s = dataMgr->getServer( servers->currentText() );
335 348 if ( s )
336 // Update url
337 s->setServerUrl( serverurl->text() );
338 s->setActive( active->isChecked() );
339
340
341 // Check if server name has changed, if it has then we need to replace the key in the map
342 if ( serverName != newName )
343 { 349 {
344 // Update server name 350 // Update url
345 s->setServerName( newName ); 351 s->setServerUrl( serverurl->text() );
346 } 352 s->setActive( active->isChecked() );
353
354 // Check if server name has changed, if it has then we need to replace the key in the map
355 if ( serverName != newName )
356 {
357 // Update server name
358 s->setServerName( newName );
359 }
347 360
348 // Update list box 361 // Update list box
349 servers->changeItem( newName, currentSelectedServer ); 362 servers->changeItem( newName, currentSelectedServer );
363 }
350 } 364 }
351 else 365 else
352 { 366 {
@@ -363,12 +377,22 @@ void SettingsImpl :: changeServerDetails()
363 377
364void SettingsImpl :: editDestination( int sel ) 378void SettingsImpl :: editDestination( int sel )
365{ 379{
366 currentSelectedDestination = sel; 380 currentSelectedDestination = sel;
367 Destination *d = dataMgr->getDestination( destinations->currentText() ); 381 Destination *d = dataMgr->getDestination( destinations->currentText() );
368 destinationName = d->getDestinationName(); 382 if ( d )
369 destinationname->setText( d->getDestinationName() ); 383 {
370 destinationurl->setText( d->getDestinationPath() ); 384 destinationName = d->getDestinationName();
371 linkToRoot->setChecked( d->linkToRoot() ); 385 destinationname->setText( d->getDestinationName() );
386 destinationurl->setText( d->getDestinationPath() );
387 linkToRoot->setChecked( d->linkToRoot() );
388 }
389 else
390 {
391 destinationName = "";
392 destinationname->setText( "" );
393 destinationurl->setText( "" );
394 linkToRoot->setChecked( false );
395 }
372} 396}
373 397
374void SettingsImpl :: newDestination() 398void SettingsImpl :: newDestination()
@@ -384,8 +408,11 @@ void SettingsImpl :: removeDestination()
384{ 408{
385 changed = true; 409 changed = true;
386 Destination *d = dataMgr->getDestination( destinations->currentText() ); 410 Destination *d = dataMgr->getDestination( destinations->currentText() );
387 dataMgr->getDestinationList().removeRef( d ); 411 if ( d )
388 destinations->removeItem( currentSelectedDestination ); 412 {
413 dataMgr->getDestinationList().removeRef( d );
414 destinations->removeItem( currentSelectedDestination );
415 }
389} 416}
390 417
391void SettingsImpl :: changeDestinationDetails() 418void SettingsImpl :: changeDestinationDetails()
@@ -401,26 +428,29 @@ void SettingsImpl :: changeDestinationDetails()
401 if ( !newdestination ) 428 if ( !newdestination )
402 { 429 {
403 Destination *d = dataMgr->getDestination( destinations->currentText() ); 430 Destination *d = dataMgr->getDestination( destinations->currentText() );
431 if ( d )
432 {
433 // Update url
434 d->setDestinationPath( destinationurl->text() );
435 d->linkToRoot( linkToRoot->isChecked() );
404 436
405 // Update url 437 // Check if server name has changed, if it has then we need to replace the key in the map
406 d->setDestinationPath( destinationurl->text() ); 438 if ( destinationName != newName )
407 d->linkToRoot( linkToRoot->isChecked() ); 439 {
440 // Update server name
441 d->setDestinationName( newName );
408 442
409 // Check if server name has changed, if it has then we need to replace the key in the map 443 // Update list box
410 if ( destinationName != newName ) 444 destinations->changeItem( newName, currentSelectedDestination );
411 { 445 }
412 // Update server name
413 d->setDestinationName( newName );
414 446
415 // Update list box
416 destinations->changeItem( newName, currentSelectedDestination );
417 }
418#ifdef QWS 447#ifdef QWS
419 QString key = newName; 448 QString key = newName;
420 key += "_linkToRoot"; 449 key += "_linkToRoot";
421 int val = d->linkToRoot(); 450 int val = d->linkToRoot();
422 cfg.writeEntry( key, val ); 451 cfg.writeEntry( key, val );
423#endif 452#endif
453 }
424 } 454 }
425 else 455 else
426 { 456 {