Skip to content

File tree

1 file changed

+33
-16
lines changed

1 file changed

+33
-16
lines changed
 

‎src/plugins/grass/qgsgrassplugin.cpp

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -714,14 +714,6 @@ void QgsGrassPlugin::projectRead()
714714
#ifdef QGISDEBUG
715715
std::cout << "QgsGrassPlugin::projectRead" << std::endl;
716716
#endif
717-
QString err = QgsGrass::closeMapset ();
718-
if ( !err.isNull() )
719-
{
720-
QMessageBox::warning( 0, "Warning",
721-
"Cannot close current mapset. " + err );
722-
return;
723-
}
724-
725717
bool ok;
726718
QString gisdbase = QgsProject::instance()->readEntry(
727719
"GRASS", "/WorkingGisdbase", "", &ok).trimmed();
@@ -730,18 +722,43 @@ void QgsGrassPlugin::projectRead()
730722
QString mapset = QgsProject::instance()->readEntry(
731723
"GRASS", "/WorkingMapset", "", &ok).trimmed();
732724

733-
if ( gisdbase.length() > 0 && location.length() > 0 &&
734-
mapset.length() > 0 )
725+
if ( gisdbase.length() == 0 || location.length() == 0 ||
726+
mapset.length() == 0 )
727+
{
728+
// Mapset not specified
729+
return;
730+
}
731+
732+
QString currentPath = QgsGrass::getDefaultGisdbase() + "/"
733+
+ QgsGrass::getDefaultLocation() + "/"
734+
+ QgsGrass::getDefaultMapset();
735+
736+
QString newPath = gisdbase + "/" + location + "/" + mapset;
737+
738+
if ( QFileInfo(currentPath).canonicalPath() ==
739+
QFileInfo(newPath).canonicalPath() )
740+
{
741+
// The same mapset is already open
742+
return;
743+
}
744+
745+
QString err = QgsGrass::closeMapset ();
746+
if ( !err.isNull() )
735747
{
736-
err = QgsGrass::openMapset ( gisdbase, location, mapset );
748+
QMessageBox::warning( 0, "Warning",
749+
"Cannot close current mapset. " + err );
750+
return;
751+
}
752+
mapsetChanged();
737753

738-
if ( !err.isNull() )
739-
{
740-
QMessageBox::warning( 0, "Warning", "Cannot open GRASS mapset. " + err );
741-
return;
742-
}
754+
err = QgsGrass::openMapset ( gisdbase, location, mapset );
743755

756+
if ( !err.isNull() )
757+
{
758+
QMessageBox::warning( 0, "Warning", "Cannot open GRASS mapset. " + err );
759+
return;
744760
}
761+
745762
mapsetChanged();
746763
}
747764

0 commit comments

Comments
 (0)
Please sign in to comment.