Skip to content
Permalink
Browse files

[GRASS] fixed tmp import maps delete on windows

  • Loading branch information
blazek committed Jun 22, 2015
1 parent 78359ec commit 5e22129866953db4a24d7f8f96a0f22cfc166708
Showing with 20 additions and 8 deletions.
  1. +8 −7 src/providers/grass/qgis.v.in.cpp
  2. +12 −1 src/providers/grass/qgsgrassprovidermodule.cpp
@@ -105,10 +105,10 @@ int main( int argc, char **argv )
exit( EXIT_FAILURE );

#ifdef Q_OS_WIN32
_setmode(_fileno(stdin), _O_BINARY);
_setmode(_fileno(stdout), _O_BINARY);
setvbuf (stdin, NULL, _IONBF, BUFSIZ);
setvbuf (stdout, NULL, _IONBF, BUFSIZ);
_setmode( _fileno( stdin ), _O_BINARY );
_setmode( _fileno( stdout ), _O_BINARY );
setvbuf( stdin, NULL, _IONBF, BUFSIZ );
setvbuf( stdout, NULL, _IONBF, BUFSIZ );
#endif
QFile stdinFile;
stdinFile.open( stdin, QIODevice::ReadOnly );
@@ -130,7 +130,8 @@ int main( int argc, char **argv )
Vect_open_new( finalMap, mapOption->answer, 0 );
struct Map_info * map = finalMap;
QDateTime now = QDateTime::currentDateTime();
QString tmpName = QString( "%1_tmp_%2" ).arg( mapOption->answer ).arg( now.toString( "yyyyMMddhhmmss" ) );
// keep tmp name in sync with QgsGrassMapsetItem::createChildren
QString tmpName = QString( "qgis_import_tmp_%1_%2" ).arg( mapOption->answer ).arg( now.toString( "yyyyMMddhhmmss" ) );
if ( isPolygon )
{
Vect_open_new( tmpMap, tmpName.toUtf8().data(), 0 );
@@ -186,7 +187,7 @@ int main( int argc, char **argv )
exitIfCanceled( stdinStream, isPolygon, tmpName, tmpMap, finalName, finalMap );
stdinStream >> feature;
#ifndef Q_OS_WIN
// cannot be used on Windows, see notes in qgis.r.in
// cannot be used on Windows, see notes in qgis.r.in
stdoutStream << ( bool )true; // feature received
stdoutFile.flush();
#endif
@@ -260,7 +261,7 @@ int main( int argc, char **argv )
attributes.insert( 0, QVariant( feature.id() ) );
try
{
// TODO: inserting row is extremely slow on Windows (at least with SQLite), v.in.ogr is fast
// TODO: inserting row is extremely slow on Windows (at least with SQLite), v.in.ogr is fast
QgsGrass::insertRow( driver, QString( fieldInfo->table ), attributes );
}
catch ( QgsGrass::Exception &e )
@@ -113,14 +113,25 @@ QgsGrassMapsetItem::QgsGrassMapsetItem( QgsDataItem* parent, QString dirPath, QS

QVector<QgsDataItem*> QgsGrassMapsetItem::createChildren()
{
QgsDebugMsg( "Entered" );
QgsDebugMsg( "Entered xxx" );

QVector<QgsDataItem*> items;

QStringList vectorNames = QgsGrass::vectors( mDirPath );

foreach ( QString name, vectorNames )
{
// Skip temporary import maps. If Vect_open_old during refresh fails due to missing topo, hist file remains open
// and Windows do no allow to delete temporary map to qgis.v.in. In any case we dont want to show temporary import maps.
// TODO: add some auto cleaning mechanism to remove temporary maps left after import fail
// keep excluded tmp name in sync with qgis.v.in
QgsDebugMsg( "name = " + name );
if ( name.startsWith( "qgis_import_tmp_" ) )
{
QgsDebugMsg( "skip tmp import vector " + name );
continue;
}

QString mapPath = mPath + "/vector/" + name;
QStringList layerNames;
try

0 comments on commit 5e22129

Please sign in to comment.
You can’t perform that action at this time.