Skip to content

Commit ebba6f7

Browse files
author
mhugent
committed
Added increment for unit iterator and added a security check if snapping unit is not there (e.g. 1.0 project file)
git-svn-id: http://svn.osgeo.org/qgis/trunk@10876 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent e72ad75 commit ebba6f7

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/app/qgsprojectproperties.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,11 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
121121
}
122122

123123
bool ok;
124+
bool toleranceUnitOk; //1.0 project files may not have a unit entry
124125
QStringList layerIdList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingList", &ok );
125126
QStringList enabledList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingEnabledList", &ok );
126127
QStringList toleranceList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceList", &ok );
127-
QStringList toleranceUnitList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceUnitList", &ok );
128+
QStringList toleranceUnitList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceUnitList", &toleranceUnitOk );
128129
QStringList snapToList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnapToList", &ok );
129130

130131
QStringList::const_iterator idIter = layerIdList.constBegin();
@@ -136,7 +137,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
136137
QgsMapLayer* currentLayer = 0;
137138

138139
//create the new layer entries
139-
for ( ; idIter != layerIdList.constEnd(); ++idIter, ++enabledIter, ++tolIter, ++snapToIter )
140+
for ( ; idIter != layerIdList.constEnd(); ++idIter, ++enabledIter, ++tolIter, ++tolUnitIter, ++snapToIter )
140141
{
141142
currentLayer = QgsMapLayerRegistry::instance()->mapLayer( *idIter );
142143
if ( currentLayer )
@@ -164,7 +165,14 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
164165
newEntry.snapTo = 2;
165166
}
166167
newEntry.tolerance = tolIter->toDouble();
167-
newEntry.toleranceUnit = tolUnitIter->toInt();
168+
if(toleranceUnitOk)
169+
{
170+
newEntry.toleranceUnit = tolUnitIter->toInt();
171+
}
172+
else
173+
{
174+
newEntry.toleranceUnit = 0;
175+
}
168176
mSnappingLayerSettings.insert( *idIter, newEntry );
169177
}
170178
}

0 commit comments

Comments
 (0)