Skip to content

Commit

Permalink
msvc warning fixes:
Browse files Browse the repository at this point in the history
* use AUTORCC to avoid locked qrc_images.cpp during build of gui tests
* bump minimum version of cmake to 3.0.0 for AUTORCC
* suppress some warnings in sip bindings
* suppress unreachable warnings and some more
* split sip files in more parts to suppress warning BK4504
* also remove old WITH_INTERNAL_YAML from travis
  • Loading branch information
jef-n committed Aug 9, 2017
1 parent d9a2492 commit 03e0298
Show file tree
Hide file tree
Showing 31 changed files with 162 additions and 62 deletions.
1 change: 0 additions & 1 deletion .ci/travis/linux/install.sh
Expand Up @@ -52,7 +52,6 @@ CMAKE_FLAGS="
-DWITH_QWTPOLAR=OFF
-DWITH_APIDOC=OFF
-DWITH_ASTYLE=OFF
-DWITH_INTERNAL_YAML=OFF
-DDISABLE_DEPRECATED=ON
-DCXX_EXTRA_FLAGS=${CLANG_WARNINGS}
"
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -21,7 +21,7 @@ MESSAGE(STATUS "QGIS version: ${COMPLETE_VERSION} ${RELEASE_NAME} (${QGIS_VERSIO
#############################################################
# CMake settings

CMAKE_MINIMUM_REQUIRED(VERSION 2.8.6)
CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0)

SET(CMAKE_COLOR_MAKEFILE ON)

Expand Down
13 changes: 8 additions & 5 deletions cmake/SIPMacros.cmake
Expand Up @@ -37,7 +37,7 @@

SET(SIP_INCLUDES)
SET(SIP_TAGS)
SET(SIP_CONCAT_PARTS 8)
SET(SIP_CONCAT_PARTS 10)
SET(SIP_DISABLE_FEATURES)
SET(SIP_EXTRA_OPTIONS)
SET(SIP_EXTRA_OBJECTS)
Expand Down Expand Up @@ -79,10 +79,13 @@ MACRO(GENERATE_SIP_PYTHON_MODULE_CODE MODULE_NAME MODULE_SIP CPP_FILES)
# Suppress warnings
IF(PEDANTIC)
IF(MSVC)
# 4996 deprecation warnings (bindings re-export deprecated methods)
# 4701 potentially uninitialized variable used (sip generated code)
# 4702 unreachable code (sip generated code)
ADD_DEFINITIONS( /wd4996 /wd4701 /wd4702 )
ADD_DEFINITIONS(
/wd4189 # local variable is initialized but not referenced
/wd4996 # deprecation warnings (bindings re-export deprecated methods)
/wd4701 # potentially uninitialized variable used (sip generated code)
/wd4702 # unreachable code (sip generated code)
/wd4703 # potentially uninitialized local pointer variable 'sipType' used
)
ELSE(MSVC)
# disable all warnings
ADD_DEFINITIONS( -w -Wno-deprecated-declarations )
Expand Down
2 changes: 1 addition & 1 deletion doc/overview.t2t
Expand Up @@ -8,7 +8,7 @@ Following a summary of the required dependencies for building:

Required build tools:

- CMake >= 2.8.6
- CMake >= 3.0.0
- Flex >= 2.5.6
- Bison >= 2.4
-
Expand Down
1 change: 0 additions & 1 deletion python/gui/qgisinterface.sip
Expand Up @@ -577,7 +577,6 @@ Unregister a previously registered action. (e.g. when plugin is going to be unlo
%End



virtual QMenu *projectMenu() = 0;
%Docstring
:rtype: QMenu
Expand Down
4 changes: 2 additions & 2 deletions scripts/sipify.pl
Expand Up @@ -463,8 +463,8 @@ sub detect_comment_block{
if ( $LINE =~ m/^\s*friend class \w+/ ){
next;
}
# Skip Q_OBJECT, Q_PROPERTY, Q_ENUM, Q_GADGET
if ($LINE =~ m/^\s*Q_(OBJECT|ENUMS|PROPERTY|GADGET|DECLARE_METATYPE|DECLARE_TYPEINFO|DECL_DEPRECATED).*?$/){
# Skip Q_OBJECT, Q_PROPERTY, Q_ENUM, Q_GADGET etc.
if ($LINE =~ m/^\s*Q_(OBJECT|ENUMS|PROPERTY|GADGET|DECLARE_METATYPE|DECLARE_TYPEINFO|DECL_DEPRECATED|NOWARN_DEPRECATED_(PUSH|POP)).*?$/){
next;
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/spell_check/check_spelling.sh
Expand Up @@ -82,7 +82,7 @@ declare -A GLOBREP_IGNORE=()
ERRORFOUND=NO

for I in $(seq -f '%02g' 0 $(($SPLIT-1)) ) ; do
( [[ "$INTERACTIVE" =~ YES ]] || [[ "$TRAVIS" =~ true ]] ) && printf "Progress: %d/%d\n" $I $SPLIT
( [[ "$INTERACTIVE" =~ YES ]] || [[ "$TRAVIS" =~ true ]] ) && printf "Progress: %d/%d\n" $(( I + 1 )) $SPLIT
SPELLFILE=spelling$I~

# if correction contains an uppercase letter and is the same as the error character wise, this means that the error is searched as a full word and case sensitive (not incorporated in a bigger one)
Expand Down
13 changes: 13 additions & 0 deletions src/app/dwg/libdxfrw/intern/dwgutil.cpp
Expand Up @@ -16,6 +16,16 @@
#include "rscodec.h"
#include "../libdwgr.h"

#if __cplusplus >= 201500
#define FALLTHROUGH [[fallthrough]];
#elif defined(__clang__)
#define FALLTHROUGH //[[clang::fallthrough]]
#elif defined(__GNUC__) && __GNUC__ >= 7
#define FALLTHROUGH [[gnu::fallthrough]];
#else
#define FALLTHROUGH
#endif

#include "qgslogger.h"

/** Utility function
Expand Down Expand Up @@ -486,6 +496,9 @@ void dwgCompressor::copyCompBytes21( duint8 *cbuf, duint8 *dbuf, duint32 l, duin
for ( int i = 1; i < 5; i++ )
dbuf[dix++] = cbuf[six + i];
dbuf[dix] = cbuf[six];

FALLTHROUGH

case 8: //OK
for ( int i = 0; i < 8; i++ ) //RLZ 4[0],4[4] or 4[4],4[0]
dbuf[dix++] = cbuf[six++];
Expand Down
14 changes: 14 additions & 0 deletions src/app/dwg/libdxfrw/libdxfrw.cpp
Expand Up @@ -24,6 +24,16 @@

#include "qgslogger.h"

#if __cplusplus >= 201500
#define FALLTHROUGH [[fallthrough]];
#elif defined(__clang__)
#define FALLTHROUGH //[[clang::fallthrough]]
#elif defined(__GNUC__) && __GNUC__ >= 7
#define FALLTHROUGH [[gnu::fallthrough]];
#else
#define FALLTHROUGH
#endif

#define FIRSTHANDLE 48

#if 0
Expand Down Expand Up @@ -3047,6 +3057,8 @@ bool dxfRW::processPolyline()
{
processVertex( &pl );
}

FALLTHROUGH
}
default:
pl.parseCode( code, reader );
Expand Down Expand Up @@ -3079,6 +3091,8 @@ bool dxfRW::processVertex( DRW_Polyline *pl )
{
v = new DRW_Vertex(); //another vertex
}

FALLTHROUGH
}
default:
v->parseCode( code, reader );
Expand Down
34 changes: 17 additions & 17 deletions src/app/dwg/qgsdwgimporter.cpp
Expand Up @@ -1395,7 +1395,7 @@ void QgsDwgImporter::addEllipse( const DRW_Ellipse &data )

bool QgsDwgImporter::curveFromLWPolyline( const DRW_LWPolyline &data, QgsCompoundCurve &cc )
{
int vertexnum = data.vertlist.size();
size_t vertexnum = data.vertlist.size();
if ( vertexnum == 0 )
{
QgsDebugMsg( "polyline without points" );
Expand All @@ -1407,7 +1407,7 @@ bool QgsDwgImporter::curveFromLWPolyline( const DRW_LWPolyline &data, QgsCompoun
std::vector<DRW_Vertex2D *>::size_type n = data.flags & 1 ? vertexnum + 1 : vertexnum;
for ( std::vector<DRW_Vertex2D *>::size_type i = 0; i < n; i++ )
{
int i0 = i % vertexnum;
size_t i0 = i % vertexnum;

Q_ASSERT( data.vertlist[i0] != nullptr );
QgsDebugMsgLevel( QString( "%1: %2,%3 bulge:%4" ).arg( i ).arg( data.vertlist[i0]->x ).arg( data.vertlist[i0]->y ).arg( data.vertlist[i0]->bulge ), 5 );
Expand Down Expand Up @@ -1439,7 +1439,7 @@ bool QgsDwgImporter::curveFromLWPolyline( const DRW_LWPolyline &data, QgsCompoun

if ( hasBulge && i < n - 1 )
{
int i1 = ( i + 1 ) % vertexnum;
size_t i1 = ( i + 1 ) % vertexnum;

double a = 2.0 * atan( data.vertlist[i]->bulge );
double dx = data.vertlist[i1]->x - data.vertlist[i0]->x;
Expand All @@ -1461,7 +1461,7 @@ bool QgsDwgImporter::curveFromLWPolyline( const DRW_LWPolyline &data, QgsCompoun

void QgsDwgImporter::addLWPolyline( const DRW_LWPolyline &data )
{
int vertexnum = data.vertlist.size();
size_t vertexnum = data.vertlist.size();
if ( vertexnum == 0 )
{
QgsDebugMsg( "LWPolyline without vertices" );
Expand All @@ -1476,8 +1476,8 @@ void QgsDwgImporter::addLWPolyline( const DRW_LWPolyline &data )
std::vector<DRW_Vertex2D *>::size_type n = data.flags & 1 ? vertexnum : vertexnum - 1;
for ( std::vector<DRW_Vertex2D *>::size_type i = 0; i < n; i++ )
{
int i0 = i % vertexnum;
int i1 = ( i + 1 ) % vertexnum;
size_t i0 = i % vertexnum;
size_t i1 = ( i + 1 ) % vertexnum;

QgsPoint p0( QgsWkbTypes::PointZ, data.vertlist[i0]->x, data.vertlist[i0]->y, data.elevation );
QgsPoint p1( QgsWkbTypes::PointZ, data.vertlist[i1]->x, data.vertlist[i1]->y, data.elevation );
Expand Down Expand Up @@ -1660,7 +1660,7 @@ void QgsDwgImporter::addLWPolyline( const DRW_LWPolyline &data )

void QgsDwgImporter::addPolyline( const DRW_Polyline &data )
{
int vertexnum = data.vertlist.size();
size_t vertexnum = data.vertlist.size();
if ( vertexnum == 0 )
{
QgsDebugMsg( "Polyline without vertices" );
Expand All @@ -1675,8 +1675,8 @@ void QgsDwgImporter::addPolyline( const DRW_Polyline &data )
std::vector<DRW_Vertex *>::size_type n = data.flags & 1 ? vertexnum : vertexnum - 1;
for ( std::vector<DRW_Vertex *>::size_type i = 0; i < n; i++ )
{
int i0 = i % vertexnum;
int i1 = ( i + 1 ) % vertexnum;
size_t i0 = i % vertexnum;
size_t i1 = ( i + 1 ) % vertexnum;

QgsPoint p0( QgsWkbTypes::PointZ, data.vertlist[i0]->basePoint.x, data.vertlist[i0]->basePoint.y, data.vertlist[i0]->basePoint.z );
QgsPoint p1( QgsWkbTypes::PointZ, data.vertlist[i1]->basePoint.x, data.vertlist[i1]->basePoint.y, data.vertlist[i1]->basePoint.z );
Expand Down Expand Up @@ -1906,24 +1906,24 @@ static std::vector<double> knotu( const DRW_Spline &data, size_t num, size_t ord
}
}

static std::vector<double> rbasis( int c, double t, int npts,
static std::vector<double> rbasis( size_t c, double t, size_t npts,
const std::vector<double> &x,
const std::vector<double> &h )
{
int nplusc = npts + c;
size_t nplusc = npts + c;
std::vector<double> temp( nplusc, 0. );

// calculate the first order nonrational basis functions n[i]
for ( int i = 0; i < nplusc - 1; ++i )
for ( size_t i = 0; i < nplusc - 1; ++i )
{
if ( t >= x[i] && t < x[i + 1] )
temp[i] = 1;
}

// calculate the higher order nonrational base functions
for ( int k = 2; k <= c; ++k )
for ( size_t k = 2; k <= c; ++k )
{
for ( int i = 0; i < nplusc - k; ++i )
for ( size_t i = 0; i < nplusc - k; ++i )
{
// if the lower order basis function is zero skip the calculation
if ( temp[i] != 0 )
Expand All @@ -1941,7 +1941,7 @@ static std::vector<double> rbasis( int c, double t, int npts,

// calculate sum for denominator of rational basis functions
double sum = 0.;
for ( int i = 0; i < npts; ++i )
for ( size_t i = 0; i < npts; ++i )
{
sum += temp[i] * h[i];
}
Expand All @@ -1951,7 +1951,7 @@ static std::vector<double> rbasis( int c, double t, int npts,
// form rational basis functions and put in r vector
if ( sum != 0.0 )
{
for ( int i = 0; i < npts; i++ )
for ( size_t i = 0; i < npts; i++ )
{
r[i] = ( temp[i] * h[i] ) / sum;
}
Expand All @@ -1969,7 +1969,7 @@ static void rbspline( const DRW_Spline &data,
const std::vector<double> &h,
std::vector<QgsPointXY> &p )
{
int nplusc = npts + k;
size_t nplusc = npts + k;

// generate the open knot vector
std::vector<double> x( knot( data, npts, k ) );
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgisappinterface.h
Expand Up @@ -33,6 +33,7 @@ class QgisApp;
* plugin.
*/

Q_NOWARN_DEPRECATED_PUSH
class APP_EXPORT QgisAppInterface : public QgisInterface
{
Q_OBJECT
Expand Down Expand Up @@ -519,5 +520,6 @@ class APP_EXPORT QgisAppInterface : public QgisInterface
//! Pointer to the PluginManagerInterface object
QgsAppPluginManagerInterface pluginManagerIface;
};
Q_NOWARN_DEPRECATED_POP

#endif //#define QGISAPPINTERFACE_H

0 comments on commit 03e0298

Please sign in to comment.