Skip to content

Commit b312571

Browse files
author
telwertowski
committed
Use QFile to determine if a proposed filename already exists. It will allow or disallow names which differ only in case depending upon platform. Fix for #1044.
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9287 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent f67777f commit b312571

File tree

1 file changed

+6
-25
lines changed

1 file changed

+6
-25
lines changed

src/plugins/grass/qgsgrassnewmapset.cpp

+6-25
Original file line numberDiff line numberDiff line change
@@ -360,18 +360,10 @@ void QgsGrassNewMapset::checkLocation()
360360
}
361361
else
362362
{
363-
QDir d( mDatabaseLineEdit->text() );
364-
365-
for ( unsigned int i = 0; i < d.count(); i++ )
363+
if ( QFile::exists( mDatabaseLineEdit->text() + "/" + location ) )
366364
{
367-
if ( d[i] == "." || d[i] == ".." ) continue;
368-
369-
if ( d[i] == location )
370-
{
371-
setNextEnabled( page( LOCATION ), false );
372-
setError( mLocationErrorLabel, tr( "The location exists!" ) );
373-
break;
374-
}
365+
setNextEnabled( page( LOCATION ), false );
366+
setError( mLocationErrorLabel, tr( "The location exists!" ) );
375367
}
376368
}
377369
}
@@ -1229,23 +1221,12 @@ void QgsGrassNewMapset::mapsetChanged()
12291221
// Check if exists
12301222
if ( mSelectLocationRadioButton->isChecked() )
12311223
{
1232-
bool exists = false;
12331224
QString locationPath = mDatabaseLineEdit->text() + "/" + mLocationComboBox->currentText();
1234-
QDir d( locationPath );
1235-
1236-
for ( unsigned int i = 0; i < d.count(); i++ )
1225+
if ( QFile::exists( locationPath + "/" + mapset ) )
12371226
{
1238-
if ( d[i] == "." || d[i] == ".." ) continue;
1239-
1240-
if ( d[i] == mapset )
1241-
{
1242-
setError( mMapsetErrorLabel, tr( "The mapset already exists" ) );
1243-
exists = true;
1244-
break;
1245-
}
1227+
setError( mMapsetErrorLabel, tr( "The mapset already exists" ) );
12461228
}
1247-
1248-
if ( !exists )
1229+
else
12491230
{
12501231
setNextEnabled( page( MAPSET ), true );
12511232
}

0 commit comments

Comments
 (0)