Skip to content

Commit 166bcd4

Browse files
committedJul 19, 2015
backport test fixes (grass & delimited text provider)
1 parent 15e5cf0 commit 166bcd4

File tree

6 files changed

+30
-14
lines changed

6 files changed

+30
-14
lines changed
 

‎src/providers/delimitedtext/qgsdelimitedtextfile.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include <QtGlobal>
2222
#include <QFile>
23+
#include <QFileInfo>
2324
#include <QDataStream>
2425
#include <QTextStream>
2526
#include <QFileSystemWatcher>
@@ -840,7 +841,6 @@ QgsDelimitedTextFile::Status QgsDelimitedTextFile::parseQuoted( QString &buffer,
840841

841842
bool QgsDelimitedTextFile::isValid()
842843
{
843-
844-
return mDefinitionValid && QFile::exists( mFileName );
844+
return mDefinitionValid && QFile::exists( mFileName ) && QFileInfo( mFileName ).size() > 0;
845845
}
846846

‎src/providers/grass/qgis.d.rast.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <string.h>
3030
#include <math.h>
3131
#include <assert.h>
32+
#include <limits.h>
3233
#ifdef WIN32
3334
#include <fcntl.h>
3435
#include <io.h>
@@ -255,8 +256,7 @@ static int cell_draw( char *name,
255256
// see comments in QgsGrassRasterProvider::noDataValue()
256257
if ( data_type == CELL_TYPE )
257258
{
258-
//int nul = -2000000000;
259-
int nul = -2147483648;
259+
int nul = INT_MIN;
260260
fwrite( &nul, 4, 1, fo );
261261
}
262262
else if ( data_type == DCELL_TYPE )

‎src/providers/grass/qgsgrass.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,11 @@ void GRASS_LIB_EXPORT QgsGrass::init( void )
333333

334334
#ifdef Q_OS_WIN
335335
// Use the applicationDirPath()/grass
336-
gisBase = shortPath( QCoreApplication::applicationDirPath() + "/grass" );
336+
#ifdef _MSC_VER
337+
gisBase = shortPath( QCoreApplication::applicationDirPath() + ( QgsApplication::isRunningFromBuildDir() ? + "/../.." : "" ) + "/grass" );
338+
#else
339+
gisBase = shortPath( QCoreApplication::applicationDirPath() + ( QgsApplication::isRunningFromBuildDir() ? + "/.." : "" ) + "/grass" );
340+
#endif
337341
QgsDebugMsg( QString( "GRASS gisBase = %1" ).arg( gisBase ) );
338342
#elif defined(Q_OS_MACX)
339343
// check for bundled GRASS, fall back to configured path
@@ -380,7 +384,7 @@ void GRASS_LIB_EXPORT QgsGrass::init( void )
380384
userGisbase = false;
381385
break;
382386
}
383-
#ifdef Q_OS_WIN32
387+
#ifdef Q_OS_WIN
384388
gisBase = shortPath( gisBase );
385389
#endif
386390
}
@@ -1692,7 +1696,7 @@ QString GRASS_LIB_EXPORT QgsGrass::getInfo( const QString& info, const QString&
16921696

16931697
QStringList arguments;
16941698

1695-
QString cmd = QgsApplication::libexecPath() + "grass/modules/qgis.g.info";
1699+
QString cmd = qgisGrassModulePath() + "/qgis.g.info";
16961700

16971701
arguments.append( "info=" + info );
16981702
if ( !map.isEmpty() )
@@ -2200,7 +2204,7 @@ QString GRASS_LIB_EXPORT QgsGrass::versionString()
22002204

22012205
Qt::CaseSensitivity GRASS_LIB_EXPORT QgsGrass::caseSensitivity()
22022206
{
2203-
#ifdef WIN32
2207+
#ifdef Q_OS_WIN
22042208
return Qt::CaseInsensitive;
22052209
#else
22062210
return Qt::CaseSensitive;
@@ -2250,7 +2254,7 @@ struct Map_info GRASS_LIB_EXPORT *QgsGrass::vectNewMapStruct()
22502254
// may have different sizes of types, see issue #13002. Because there is no Vect_new_map_struct (GRASS 7.0.0, July 2015)
22512255
// the structure is allocated here using doubled (should be enough) space.
22522256
// TODO: replace by Vect_new_map_struct once it appears in GRASS
2253-
#if defined(WIN32)
2257+
#ifdef Q_OS_WIN
22542258
return ( struct Map_info* ) qgsMalloc( 2*sizeof( struct Map_info ) );
22552259
#else
22562260
return ( struct Map_info* ) qgsMalloc( sizeof( struct Map_info ) );

‎src/providers/grass/qgsgrass.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class QgsGrass
147147
};
148148

149149
//! Get info about the mode
150-
/*! QgsGrass may be running in active or passive mode.
150+
/** QgsGrass may be running in active or passive mode.
151151
* Active mode means that GISRC is set up and GISRC file is available,
152152
* in that case default GISDBASE, LOCATION and MAPSET may be read by GetDefaul*() functions.
153153
* Passive mode means, that GISRC is not available. */
@@ -409,12 +409,21 @@ class QgsGrass
409409
// set environment variable
410410
static GRASS_LIB_EXPORT void putEnv( QString name, QString value );
411411

412-
#if defined(WIN32)
412+
#ifdef Q_OS_WIN
413413
static GRASS_LIB_EXPORT QString shortPath( const QString &path );
414414
#endif
415415

416416
// path to QGIS GRASS modules like qgis.g.info etc.
417-
static GRASS_LIB_EXPORT QString qgisGrassModulePath() { return QgsApplication::libexecPath() + "grass/modules"; }
417+
static GRASS_LIB_EXPORT QString qgisGrassModulePath()
418+
{
419+
#ifdef _MSC_VER
420+
if ( QgsApplication::isRunningFromBuildDir() )
421+
{
422+
return QCoreApplication::applicationDirPath() + "/../../grass/modules/" + QgsApplication::cfgIntDir();
423+
}
424+
#endif
425+
return QgsApplication::libexecPath() + "grass/modules";
426+
}
418427

419428
// Allocate struct Map_info
420429
static GRASS_LIB_EXPORT struct Map_info * vectNewMapStruct();

‎src/providers/grass/qgsgrassrasterprovider.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ QgsGrassRasterProvider::QgsGrassRasterProvider( QString const & uri )
108108
double myInternalNoDataValue;
109109
if ( mGrassDataType == CELL_TYPE )
110110
{
111-
myInternalNoDataValue = -2147483648;
111+
myInternalNoDataValue = INT_MIN;
112112
}
113113
else if ( mGrassDataType == DCELL_TYPE )
114114
{

‎tests/src/providers/grass/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ MACRO (ADD_QGIS_GRASS_TEST grass_build_version testname testsrc)
2626
IF(WIN32 AND NOT USING_NMAKE)
2727
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${testname}.cmake
2828
"
29-
SET(ENV{PATH} \"${GRASS_PREFIX${grass_build_version}}/lib;${CMAKE_BINARY_DIR}/output/bin/\${CMAKE_BUILD_TYPE};${CMAKE_BINARY_DIR}/output/plugins/\${CMAKE_BUILD_TYPE};\$ENV{PATH}\")
29+
SET(ENV{PATH} \"${GRASS_PREFIX${grass_build_version}}/bin;${GRASS_PREFIX${grass_build_version}}/lib;${CMAKE_BINARY_DIR}/output/bin/\${CMAKE_BUILD_TYPE};${CMAKE_BINARY_DIR}/output/plugins/\${CMAKE_BUILD_TYPE};\$ENV{PATH}\")
30+
SET(ENV{GISBASE} \"${GRASS_PREFIX${grass_build_version}}\")
3031
MESSAGE(STATUS \"Running ${CMAKE_BINARY_DIR}/output/bin/\${CMAKE_BUILD_TYPE}/qgis_${testname}${grass_build_version}\")
32+
MESSAGE(STATUS \"PATH:\$ENV{PATH}\")
33+
MESSAGE(STATUS \"GISBASE:\$ENV{GISBASE}\")
3134
EXECUTE_PROCESS(
3235
COMMAND ${CMAKE_BINARY_DIR}/output/bin/\${CMAKE_BUILD_TYPE}/qgis_${testname}${grass_build_version}
3336
RESULT_VARIABLE import_res

0 commit comments

Comments
 (0)
Please sign in to comment.