Skip to content
Permalink
Browse files

check better if the mapset is already open

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5026 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek
rblazek committed Mar 15, 2006
1 parent 6bfb85c commit dad6faadc64e4357d760fe5cf7469261a47ef89e
Showing with 33 additions and 16 deletions.
  1. +33 −16 src/plugins/grass/qgsgrassplugin.cpp
@@ -714,14 +714,6 @@ void QgsGrassPlugin::projectRead()
#ifdef QGISDEBUG
std::cout << "QgsGrassPlugin::projectRead" << std::endl;
#endif
QString err = QgsGrass::closeMapset ();
if ( !err.isNull() )
{
QMessageBox::warning( 0, "Warning",
"Cannot close current mapset. " + err );
return;
}

bool ok;
QString gisdbase = QgsProject::instance()->readEntry(
"GRASS", "/WorkingGisdbase", "", &ok).trimmed();
@@ -730,18 +722,43 @@ void QgsGrassPlugin::projectRead()
QString mapset = QgsProject::instance()->readEntry(
"GRASS", "/WorkingMapset", "", &ok).trimmed();

if ( gisdbase.length() > 0 && location.length() > 0 &&
mapset.length() > 0 )
if ( gisdbase.length() == 0 || location.length() == 0 ||
mapset.length() == 0 )
{
// Mapset not specified
return;
}

QString currentPath = QgsGrass::getDefaultGisdbase() + "/"
+ QgsGrass::getDefaultLocation() + "/"
+ QgsGrass::getDefaultMapset();

QString newPath = gisdbase + "/" + location + "/" + mapset;

if ( QFileInfo(currentPath).canonicalPath() ==
QFileInfo(newPath).canonicalPath() )
{
// The same mapset is already open
return;
}

QString err = QgsGrass::closeMapset ();
if ( !err.isNull() )
{
err = QgsGrass::openMapset ( gisdbase, location, mapset );
QMessageBox::warning( 0, "Warning",
"Cannot close current mapset. " + err );
return;
}
mapsetChanged();

if ( !err.isNull() )
{
QMessageBox::warning( 0, "Warning", "Cannot open GRASS mapset. " + err );
return;
}
err = QgsGrass::openMapset ( gisdbase, location, mapset );

if ( !err.isNull() )
{
QMessageBox::warning( 0, "Warning", "Cannot open GRASS mapset. " + err );
return;
}

mapsetChanged();
}

0 comments on commit dad6faa

Please sign in to comment.
You can’t perform that action at this time.