Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix size_t vs. int warnings
  • Loading branch information
jef-n committed Sep 6, 2013
1 parent 029927f commit 8fffd53
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/analysis/openstreetmap/qgsosmdatabase.cpp
Expand Up @@ -421,7 +421,7 @@ void QgsOSMDatabase::exportSpatiaLiteNodes( const QString& tableName, const QStr
sqlite3_bind_null( stmtInsert, ++col );
}

sqlite3_bind_blob( stmtInsert, ++col, geom->asWkb(), geom->wkbSize(), SQLITE_STATIC );
sqlite3_bind_blob( stmtInsert, ++col, geom->asWkb(), (int) geom->wkbSize(), SQLITE_STATIC );

int insertRes = sqlite3_step( stmtInsert );
if ( insertRes != SQLITE_DONE )
Expand Down Expand Up @@ -489,7 +489,7 @@ void QgsOSMDatabase::exportSpatiaLiteWays( bool closed, const QString& tableName
sqlite3_bind_null( stmtInsert, ++col );
}

sqlite3_bind_blob( stmtInsert, ++col, geom->asWkb(), geom->wkbSize(), SQLITE_STATIC );
sqlite3_bind_blob( stmtInsert, ++col, geom->asWkb(), (int) geom->wkbSize(), SQLITE_STATIC );

int insertRes = sqlite3_step( stmtInsert );
if ( insertRes != SQLITE_DONE )
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsvectorfilewriter.cpp
Expand Up @@ -669,7 +669,7 @@ OGRFeatureH QgsVectorFileWriter::createFeature( QgsFeature& feature )
return 0;
}

OGRErr err = OGR_G_ImportFromWkb( mGeom2, const_cast<unsigned char *>( geom->asWkb() ), geom->wkbSize() );
OGRErr err = OGR_G_ImportFromWkb( mGeom2, const_cast<unsigned char *>( geom->asWkb() ), (int) geom->wkbSize() );
if ( err != OGRERR_NONE )
{
mErrorMessage = QObject::tr( "Feature geometry not imported (OGR error: %1)" )
Expand All @@ -685,7 +685,7 @@ OGRFeatureH QgsVectorFileWriter::createFeature( QgsFeature& feature )
}
else if ( geom )
{
OGRErr err = OGR_G_ImportFromWkb( mGeom, const_cast<unsigned char *>( geom->asWkb() ), geom->wkbSize() );
OGRErr err = OGR_G_ImportFromWkb( mGeom, const_cast<unsigned char *>( geom->asWkb() ), (int) geom->wkbSize() );
if ( err != OGRERR_NONE )
{
mErrorMessage = QObject::tr( "Feature geometry not imported (OGR error: %1)" )
Expand Down
4 changes: 2 additions & 2 deletions src/core/raster/qgsrasterblock.cpp
Expand Up @@ -324,7 +324,7 @@ bool QgsRasterBlock::isNoData( size_t index )
return false;
}
// TODO: optimize
int row = index / mWidth;
int row = (int) index / mWidth;
int column = index % mWidth;
size_t byte = ( size_t )row * mNoDataBitmapWidth + column / 8 ;
int bit = column % 8;
Expand Down Expand Up @@ -406,7 +406,7 @@ bool QgsRasterBlock::setIsNoData( size_t index )
}
}
// TODO: optimize
int row = index / mWidth;
int row = (int) index / mWidth;
int column = index % mWidth;
size_t byte = ( size_t )row * mNoDataBitmapWidth + column / 8;
int bit = column % 8;
Expand Down
9 changes: 4 additions & 5 deletions src/plugins/grass/qgsgrassedit.cpp
Expand Up @@ -572,12 +572,11 @@ void QgsGrassEdit::setAttributeTable( int field )

if ( !key->isEmpty() ) // Database link defined
{
std::vector<QgsField> *cols = mProvider->columns( field );
QVector<QgsField> *cols = mProvider->columns( field );

mAttributeTable->setRowCount( cols->size() );


for ( unsigned int c = 0; c < cols->size(); c++ )
for ( int c = 0; c < cols->size(); c++ )
{
QgsField col = ( *cols )[c];

Expand Down Expand Up @@ -1463,7 +1462,7 @@ void QgsGrassEdit::addAttributes( int field, int cat )

if ( !key->isEmpty() ) // Database link defined
{
std::vector<QgsField> *cols = mProvider->columns( field );
QVector<QgsField> *cols = mProvider->columns( field );

if ( cols->size() == 0 )
{
Expand All @@ -1481,7 +1480,7 @@ void QgsGrassEdit::addAttributes( int field, int cat )
}
else
{
for ( unsigned int j = 0; j < cols->size(); j++ )
for ( int j = 0; j < cols->size(); j++ )
{
QgsField col = ( *cols )[j];
QVariant att = ( *atts )[j];
Expand Down
24 changes: 12 additions & 12 deletions src/providers/grass/qgsgrassprovider.cpp
Expand Up @@ -62,8 +62,8 @@ extern "C"
#endif


std::vector<GLAYER> QgsGrassProvider::mLayers;
std::vector<GMAP> QgsGrassProvider::mMaps;
QVector<GLAYER> QgsGrassProvider::mLayers;
QVector<GMAP> QgsGrassProvider::mMaps;


static QString GRASS_KEY = "grass"; // XXX verify this
Expand Down Expand Up @@ -370,7 +370,7 @@ int QgsGrassProvider::openLayer( QString gisdbase, QString location, QString map

// Check if this layer is already opened

for ( unsigned int i = 0; i < mLayers.size(); i++ )
for ( int i = 0; i < mLayers.size(); i++ )
{
if ( !( mLayers[i].valid ) )
continue;
Expand Down Expand Up @@ -719,7 +719,7 @@ int QgsGrassProvider::openMap( QString gisdbase, QString location, QString mapse
QString tmpPath = gisdbase + "/" + location + "/" + mapset + "/" + mapName;

// Check if this map is already opened
for ( unsigned int i = 0; i < mMaps.size(); i++ )
for ( int i = 0; i < mMaps.size(); i++ )
{
if ( mMaps[i].valid && mMaps[i].path == tmpPath )
{
Expand Down Expand Up @@ -869,7 +869,7 @@ void QgsGrassProvider::updateMap( int mapId )
QgsDebugMsg( QString( "Cannot reopen GRASS vector: %1" ).arg( e.what() ) );

// if reopen fails, mLayers should be also updated
for ( unsigned int i = 0; i < mLayers.size(); i++ )
for ( int i = 0; i < mLayers.size(); i++ )
{
if ( mLayers[i].mapId == mapId )
{
Expand All @@ -881,7 +881,7 @@ void QgsGrassProvider::updateMap( int mapId )

QgsDebugMsg( "GRASS map successfully reopened for reading." );

for ( unsigned int i = 0; i < mLayers.size(); i++ )
for ( int i = 0; i < mLayers.size(); i++ )
{
// if ( !(mLayers[i].valid) )
// continue; // ?
Expand Down Expand Up @@ -1365,7 +1365,7 @@ bool QgsGrassProvider::reopenMap()
QgsDebugMsg( "GRASS map successfully reopened for reading." );

// Reload sources to layers
for ( unsigned int i = 0; i < mLayers.size(); i++ )
for ( int i = 0; i < mLayers.size(); i++ )
{
// if ( !(mLayers[i].valid) )
// continue; // ?
Expand Down Expand Up @@ -1609,19 +1609,19 @@ QString *QgsGrassProvider::key( int field )
return key;
}

std::vector<QgsField> *QgsGrassProvider::columns( int field )
QVector<QgsField> *QgsGrassProvider::columns( int field )
{
QgsDebugMsg( QString( "field = %1" ).arg( field ) );

std::vector<QgsField> *col = new std::vector<QgsField>;
QVector<QgsField> *col = new QVector<QgsField>;

struct field_info *fi = Vect_get_field( mMap, field ); // should work also with field = 0

// Read attributes
if ( !fi )
{
QgsDebugMsg( "No field info -> no attributes" );
return ( col );
return col;
}

QgsDebugMsg( "Field info found -> open database" );
Expand All @@ -1631,7 +1631,7 @@ std::vector<QgsField> *QgsGrassProvider::columns( int field )
if ( !driver )
{
QgsDebugMsg( QString( "Cannot open database %1 by driver %2" ).arg( fi->database ).arg( fi->driver ) );
return ( col );
return col;
}

QgsDebugMsg( "Database opened -> describe table" );
Expand All @@ -1644,7 +1644,7 @@ std::vector<QgsField> *QgsGrassProvider::columns( int field )
if ( db_describe_table( driver, &tableName, &table ) != DB_OK )
{
QgsDebugMsg( "Cannot describe table" );
return ( col );
return col;
}

int nCols = db_get_table_number_of_columns( table );
Expand Down
6 changes: 3 additions & 3 deletions src/providers/grass/qgsgrassprovider.h
Expand Up @@ -352,7 +352,7 @@ class GRASS_LIB_EXPORT QgsGrassProvider : public QgsVectorDataProvider
* @param cat
* @return vector of attributes
*/
std::vector<QgsField> *columns( int field );
QVector<QgsField> *columns( int field );

/** Read attributes from DB
* @param field
Expand Down Expand Up @@ -640,8 +640,8 @@ class GRASS_LIB_EXPORT QgsGrassProvider : public QgsVectorDataProvider
void ensureUpdated();

/* Static arrays of opened layers and vectors */
static std::vector<GLAYER> mLayers; // Map + field/attributes
static std::vector<GMAP> mMaps; // Map
static QVector<GLAYER> mLayers; // Map + field/attributes
static QVector<GMAP> mMaps; // Map

friend class QgsGrassFeatureIterator;
QSet< QgsGrassFeatureIterator *> mActiveIterators;
Expand Down

0 comments on commit 8fffd53

Please sign in to comment.