[QGIS Commit] r9245 - trunk/qgis/src/providers/grass

svn_qgis at osgeo.org svn_qgis at osgeo.org
Tue Sep 2 11:06:57 EDT 2008


Author: jef
Date: 2008-09-02 11:06:57 -0400 (Tue, 02 Sep 2008)
New Revision: 9245

Modified:
   trunk/qgis/src/providers/grass/qgsgrass.cpp
Log:
workaround for non-functional lock.exe on windows (fixes #808)

Modified: trunk/qgis/src/providers/grass/qgsgrass.cpp
===================================================================
--- trunk/qgis/src/providers/grass/qgsgrass.cpp	2008-09-02 15:02:53 UTC (rev 9244)
+++ trunk/qgis/src/providers/grass/qgsgrass.cpp	2008-09-02 15:06:57 UTC (rev 9245)
@@ -452,6 +452,20 @@
 
   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
@@ -473,18 +487,14 @@
   // TODO better wait
   while ( process->isRunning() ) { }
 
-#ifndef WIN32
   int status = process->exitStatus();
   QgsDebugMsg( QString( "status = %1" ).arg( status ) );
-#endif
   delete process;
 
+  if ( status > 0 )
+    return QObject::tr( "Mapset is already in use." );
+#endif // !WIN32
 
-  // TODO WIN32 (lock.exe does not work properly?)
-#ifndef WIN32
-  if ( status > 0 ) return QObject::tr( "Mapset is already in use." );
-#endif
-
   // Create temporary directory
   QFileInfo info( mapsetPath );
   QString user = info.owner();



More information about the QGIS-commit mailing list