Skip to content

Commit

Permalink
fix #4736
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n authored and alexbruy committed Jan 3, 2012
1 parent 839c575 commit 6e49e55
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions src/providers/grass/qgsgrass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,31 +453,13 @@ QString GRASS_LIB_EXPORT QgsGrass::openMapset( QString gisdbase, QString locatio
return QObject::tr( "%1 is not a GRASS mapset." ).arg( mapsetPath );
}

#ifndef Q_OS_WIN
QString lock = mapsetPath + "/.gislock";
QFile lockFile( lock );
#if WIN32
// lock on Windows doesn't support locking (see #808)
if ( lockFile.exists() )
return QObject::tr( "Mapset is already in use." );

lockFile.open( QIODevice::WriteOnly );
#ifndef _MSC_VER
int pid = getpid();
#else
int pid = GetCurrentProcessId();
#endif
lockFile.write( QString( "%1" ).arg( pid ).toUtf8() );
lockFile.close();
#else
QProcess *process = new QProcess();
QString lockProgram( gisBase + "/etc/lock" );

// TODO: getpid() probably is not portable
#ifndef _MSC_VER
int pid = getpid();
#else
int pid = GetCurrentProcessId();
#endif
QgsDebugMsg( QString( "pid = %1" ).arg( pid ) );

process->start( lockProgram, QStringList() << lock << QString::number( pid ) );
Expand Down

0 comments on commit 6e49e55

Please sign in to comment.