Skip to content

Commit

Permalink
[GRASS] fixed tmp import maps delete on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed Jun 22, 2015
1 parent 78359ec commit 5e22129
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
15 changes: 8 additions & 7 deletions src/providers/grass/qgis.v.in.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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 );
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 )
Expand Down
13 changes: 12 additions & 1 deletion src/providers/grass/qgsgrassprovidermodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5e22129

Please sign in to comment.