From b86bb6f7874c0a8223a5916642a03a573d74d0b3 Mon Sep 17 00:00:00 2001 From: "Juergen E. Fischer" Date: Mon, 27 Feb 2012 18:13:07 +0100 Subject: [PATCH] fix crash in CRS selection --- src/gui/qgsprojectionselector.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/gui/qgsprojectionselector.cpp b/src/gui/qgsprojectionselector.cpp index fb81c445e1d..e46aa3bb83c 100644 --- a/src/gui/qgsprojectionselector.cpp +++ b/src/gui/qgsprojectionselector.cpp @@ -710,11 +710,18 @@ void QgsProjectionSelector::loadCrsList( QSet *crsFilter ) void QgsProjectionSelector::on_lstCoordinateSystems_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem * ) { QgsDebugMsg( "Entered." ); + + if ( !current ) + { + QgsDebugMsg( "no current item" ); + return; + } + lstCoordinateSystems->scrollToItem( current ); // If the item has children, it's not an end node in the tree, and // hence is just a grouping thingy, not an actual CRS. - if ( current && current->childCount() == 0 ) + if ( current->childCount() == 0 ) { // Found a real CRS emit sridSelected( QString::number( selectedCrsId() ) ); @@ -736,8 +743,7 @@ void QgsProjectionSelector::on_lstCoordinateSystems_currentItemChanged( QTreeWid else { // Not an CRS - remove the highlight so the user doesn't get too confused - if ( current ) - current->setSelected( false ); + current->setSelected( false ); teProjection->setText( "" ); lstRecent->clearSelection(); } @@ -746,6 +752,13 @@ void QgsProjectionSelector::on_lstCoordinateSystems_currentItemChanged( QTreeWid void QgsProjectionSelector::on_lstRecent_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem * ) { QgsDebugMsg( "Entered." ); + + if ( !current ) + { + QgsDebugMsg( "no current item" ); + return; + } + lstRecent->scrollToItem( current ); QList nodes = lstCoordinateSystems->findItems( current->text( QGIS_CRS_ID_COLUMN ), Qt::MatchExactly | Qt::MatchRecursive, QGIS_CRS_ID_COLUMN );