Skip to content

Commit

Permalink
workaround for non-functional lock.exe on windows (fixes #808)
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9245 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Sep 2, 2008
1 parent ba96ab1 commit 9f02d0d
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/providers/grass/qgsgrass.cpp
Expand Up @@ -452,6 +452,20 @@ QString GRASS_EXPORT QgsGrass::openMapset( QString gisdbase, QString location, Q

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 ).toLocal8Bit() );
lockFile.close();
#else
Q3Process *process = new Q3Process();
process->addArgument( gisBase + "/etc/lock" ); // lock program
process->addArgument( lock ); // lock file
Expand All @@ -473,17 +487,13 @@ QString GRASS_EXPORT QgsGrass::openMapset( QString gisdbase, QString location, Q
// TODO better wait
while ( process->isRunning() ) { }

#ifndef WIN32
int status = process->exitStatus();
QgsDebugMsg( QString( "status = %1" ).arg( status ) );
#endif
delete process;


// TODO WIN32 (lock.exe does not work properly?)
#ifndef WIN32
if ( status > 0 ) return QObject::tr( "Mapset is already in use." );
#endif
if ( status > 0 )
return QObject::tr( "Mapset is already in use." );
#endif // !WIN32

// Create temporary directory
QFileInfo info( mapsetPath );
Expand Down

0 comments on commit 9f02d0d

Please sign in to comment.