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 5a6e830 commit fb1dada
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 @@ -451,31 +451,13 @@ QString GRASS_EXPORT QgsGrass::openMapset( QString gisdbase, QString location, Q
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 fb1dada

Please sign in to comment.