Skip to content
Permalink
Browse files

Fix more warnings when building under clang with -wEverything

  • Loading branch information
nyalldawson committed Jan 2, 2016
1 parent 144ca8d commit 2eb95f081ff638898c05724f75874e3f1f3c504f
@@ -120,5 +120,5 @@ def quote(v):
cpp.write("\n\n gFunctionHelpTexts.insert( \"{0}\",\n Help( tr( \"{0}\" ), tr( \"group\" ), tr( \"{1}\" ), QList<HelpVariant>() ) );\n".format(
n, content.read().replace("\\", "&#92;").replace('\\', '\\\\').replace('"', '\\"').replace('\n', '\\n')))

cpp.write("\n}")
cpp.write("\n}\n")
cpp.close()
@@ -2564,7 +2564,7 @@ void QgisApp::createOverview()

int action = mySettings.value( "/qgis/wheel_action", 2 ).toInt();
double zoomFactor = mySettings.value( "/qgis/zoom_factor", 2 ).toDouble();
mMapCanvas->setWheelAction(( QgsMapCanvas::WheelAction ) action, zoomFactor );
mMapCanvas->setWheelAction( static_cast< QgsMapCanvas::WheelAction >( action ), zoomFactor );

mMapCanvas->setCachingEnabled( mySettings.value( "/qgis/enable_render_caching", true ).toBool() );

@@ -3015,13 +3015,13 @@ void QgisApp::restoreWindowState()
// restore the toolbar and dock widgets positions using Qt4 settings API
QSettings settings;

if ( !restoreState( settings.value( "/UI/state", QByteArray::fromRawData(( char * )defaultUIstate, sizeof defaultUIstate ) ).toByteArray() ) )
if ( !restoreState( settings.value( "/UI/state", QByteArray::fromRawData( reinterpret_cast< const char * >( defaultUIstate ), sizeof defaultUIstate ) ).toByteArray() ) )
{
QgsDebugMsg( "restore of UI state failed" );
}

// restore window geometry
if ( !restoreGeometry( settings.value( "/UI/geometry", QByteArray::fromRawData(( char * )defaultUIgeometry, sizeof defaultUIgeometry ) ).toByteArray() ) )
if ( !restoreGeometry( settings.value( "/UI/geometry", QByteArray::fromRawData( reinterpret_cast< const char * >( defaultUIgeometry ), sizeof defaultUIgeometry ) ).toByteArray() ) )
{
QgsDebugMsg( "restore of UI geometry failed" );
}
@@ -3970,7 +3970,7 @@ void QgisApp::fileNew( bool thePromptToSaveFlag, bool forceBlank )
// write the projections _proj string_ to project settings
prj->writeEntry( "SpatialRefSys", "/ProjectCRSProj4String", srs.toProj4() );
prj->writeEntry( "SpatialRefSys", "/ProjectCrs", srs.authid() );
prj->writeEntry( "SpatialRefSys", "/ProjectCRSID", ( int ) srs.srsid() );
prj->writeEntry( "SpatialRefSys", "/ProjectCRSID", static_cast< int >( srs.srsid() ) );
prj->dirty( false );
if ( srs.mapUnits() != QGis::UnknownUnit )
{
@@ -5621,7 +5621,7 @@ void QgisApp::saveAsVectorFileGeneral( QgsVectorLayer* vlayer, bool symbologyOpt
datasourceOptions, dialog->layerOptions(),
dialog->skipAttributeCreation(),
&newFilename,
( QgsVectorFileWriter::SymbologyExport )( dialog->symbologyExport() ),
static_cast< QgsVectorFileWriter::SymbologyExport >( dialog->symbologyExport() ),
dialog->scaleDenominator(),
dialog->hasFilterExtent() ? &filterExtent : nullptr,
autoGeometryType ? QgsWKBTypes::Unknown : forcedGeometryType,
@@ -7949,7 +7949,7 @@ void QgisApp::loadPythonSupport()

//QgsDebugMsg("Python support library loaded successfully.");
typedef QgsPythonUtils*( *inst )();
inst pythonlib_inst = ( inst ) cast_to_fptr( pythonlib.resolve( "instance" ) );
inst pythonlib_inst = reinterpret_cast< inst >( cast_to_fptr( pythonlib.resolve( "instance" ) ) );
if ( !pythonlib_inst )
{
//using stderr on purpose because we want end users to see this [TS]
@@ -8063,7 +8063,7 @@ void QgisApp::showOptionsDialog( QWidget *parent, const QString& currentPage )

int action = mySettings.value( "/qgis/wheel_action", 2 ).toInt();
double zoomFactor = mySettings.value( "/qgis/zoom_factor", 2 ).toDouble();
mMapCanvas->setWheelAction(( QgsMapCanvas::WheelAction ) action, zoomFactor );
mMapCanvas->setWheelAction( static_cast< QgsMapCanvas::WheelAction >( action ), zoomFactor );

mMapCanvas->setCachingEnabled( mySettings.value( "/qgis/enable_render_caching", true ).toBool() );

@@ -10432,7 +10432,7 @@ void QgisApp::writeProject( QDomDocument &doc )
delete clonedRoot;
doc.firstChildElement( "qgis" ).appendChild( oldLegendElem );

QgsProject::instance()->writeEntry( "Legend", "filterByMap", ( bool ) layerTreeView()->layerTreeModel()->legendFilterMapSettings() );
QgsProject::instance()->writeEntry( "Legend", "filterByMap", static_cast< bool >( layerTreeView()->layerTreeModel()->legendFilterMapSettings() ) );

projectChanged( doc );
}
@@ -10801,8 +10801,8 @@ void QgisApp::authMessageOut( const QString& message, const QString& authtag, Qg
if ( qApp->activeWindow() != this )
return;

int levelint = ( int )level;
messageBar()->pushMessage( authtag, message, ( QgsMessageBar::MessageLevel )levelint, 7 );
int levelint = static_cast< int >( level );
messageBar()->pushMessage( authtag, message, static_cast< QgsMessageBar::MessageLevel >( levelint ), 7 );
}

void QgisApp::completeInitialization()
@@ -270,7 +270,7 @@ bool QgsComposerTable::tableWriteXML( QDomElement& elem, QDomDocument & doc ) co
elem.setAttribute( "lineTextDist", QString::number( mLineTextDistance ) );
elem.appendChild( QgsFontUtils::toXmlElement( mHeaderFont, doc, "headerFontProperties" ) );
elem.setAttribute( "headerFontColor", QgsSymbolLayerV2Utils::encodeColor( mHeaderFontColor ) );
elem.setAttribute( "headerHAlignment", QString::number(( int )mHeaderHAlignment ) );
elem.setAttribute( "headerHAlignment", QString::number( static_cast< int >( mHeaderHAlignment ) ) );
elem.appendChild( QgsFontUtils::toXmlElement( mContentFont, doc, "contentFontProperties" ) );
elem.setAttribute( "contentFontColor", QgsSymbolLayerV2Utils::encodeColor( mContentFontColor ) );
elem.setAttribute( "gridStrokeWidth", QString::number( mGridStrokeWidth ) );
@@ -109,20 +109,20 @@ QgsComposerTableV2::~QgsComposerTableV2()
bool QgsComposerTableV2::writeXML( QDomElement& elem, QDomDocument & doc, bool ignoreFrames ) const
{
elem.setAttribute( "cellMargin", QString::number( mCellMargin ) );
elem.setAttribute( "emptyTableMode", QString::number(( int )mEmptyTableMode ) );
elem.setAttribute( "emptyTableMode", QString::number( static_cast< int >( mEmptyTableMode ) ) );
elem.setAttribute( "emptyTableMessage", mEmptyTableMessage );
elem.setAttribute( "showEmptyRows", mShowEmptyRows );
elem.appendChild( QgsFontUtils::toXmlElement( mHeaderFont, doc, "headerFontProperties" ) );
elem.setAttribute( "headerFontColor", QgsSymbolLayerV2Utils::encodeColor( mHeaderFontColor ) );
elem.setAttribute( "headerHAlignment", QString::number(( int )mHeaderHAlignment ) );
elem.setAttribute( "headerMode", QString::number(( int )mHeaderMode ) );
elem.setAttribute( "headerHAlignment", QString::number( static_cast< int >( mHeaderHAlignment ) ) );
elem.setAttribute( "headerMode", QString::number( static_cast< int >( mHeaderMode ) ) );
elem.appendChild( QgsFontUtils::toXmlElement( mContentFont, doc, "contentFontProperties" ) );
elem.setAttribute( "contentFontColor", QgsSymbolLayerV2Utils::encodeColor( mContentFontColor ) );
elem.setAttribute( "gridStrokeWidth", QString::number( mGridStrokeWidth ) );
elem.setAttribute( "gridColor", QgsSymbolLayerV2Utils::encodeColor( mGridColor ) );
elem.setAttribute( "showGrid", mShowGrid );
elem.setAttribute( "backgroundColor", QgsSymbolLayerV2Utils::encodeColor( mBackgroundColor ) );
elem.setAttribute( "wrapBehaviour", QString::number(( int )mWrapBehaviour ) );
elem.setAttribute( "wrapBehaviour", QString::number( static_cast< int >( mWrapBehaviour ) ) );

//columns
QDomElement displayColumnsElem = doc.createElement( "displayColumns" );
@@ -435,7 +435,7 @@ void QgsComposerTableV2::render( QPainter *p, const QRectF &, const int frameInd

currentX += mCellMargin;

Qt::TextFlag textFlag = ( Qt::TextFlag )0;
Qt::TextFlag textFlag = static_cast< Qt::TextFlag >( 0 );
if (( *columnIt )->width() <= 0 )
{
//automatic column width, so we use the Qt::TextDontClip flag when drawing contents, as this works nicer for italicised text
@@ -506,7 +506,7 @@ void QgsComposerTableV2::render( QPainter *p, const QRectF &, const int frameInd
QVariant cellContents = mTableContents.at( row ).at( col );
QString str = cellContents.toString();

Qt::TextFlag textFlag = ( Qt::TextFlag )0;
Qt::TextFlag textFlag = static_cast< Qt::TextFlag >( 0 );
if (( *columnIt )->width() <= 0 && mWrapBehaviour == TruncateText )
{
//automatic column width, so we use the Qt::TextDontClip flag when drawing contents, as this works nicer for italicised text
@@ -587,7 +587,7 @@ void QgsComposerTableV2::render( QPainter *p, const QRectF &, const int frameInd
double messageX = gridSize + mCellMargin;
double messageY = gridSize + ( drawHeader ? cellHeaderHeight + gridSize : 0 );
cell = QRectF( messageX, messageY, mTableSize.width() - messageX, cellBodyHeight );
QgsComposerUtils::drawText( p, cell, mEmptyTableMessage, mContentFont, mContentFontColor, Qt::AlignHCenter, Qt::AlignVCenter, ( Qt::TextFlag )0 );
QgsComposerUtils::drawText( p, cell, mEmptyTableMessage, mContentFont, mContentFontColor, Qt::AlignHCenter, Qt::AlignVCenter, static_cast< Qt::TextFlag >( 0 ) );
}

p->restore();
@@ -596,7 +596,7 @@ void QgsComposerTableV2::render( QPainter *p, const QRectF &, const int frameInd

void QgsComposerTableV2::setCellMargin( const double margin )
{
if ( margin == mCellMargin )
if ( qgsDoubleNear( margin, mCellMargin ) )
{
return;
}
@@ -747,7 +747,7 @@ void QgsComposerTableV2::setShowGrid( const bool showGrid )

void QgsComposerTableV2::setGridStrokeWidth( const double width )
{
if ( width == mGridStrokeWidth )
if ( qgsDoubleNear( width, mGridStrokeWidth ) )
{
return;
}
@@ -1163,7 +1163,7 @@ void QgsComposerTableV2::drawVerticalGridLines( QPainter *painter, const QMap<in

bool QgsComposerTableV2::textRequiresWrapping( const QString& text, double columnWidth, const QFont &font ) const
{
if ( columnWidth == 0 || mWrapBehaviour != WrapText )
if ( qgsDoubleNear( columnWidth, 0.0 ) || mWrapBehaviour != WrapText )
return false;

QStringList multiLineSplit = text.split( '\n' );
@@ -681,7 +681,7 @@ void QgsProjectFileTransform::convertRasterProperties( QDomDocument& doc, QDomNo
QDomElement colorRampEntryElem = colorRampEntryList.at( i ).toElement();
QString strValue = colorRampEntryElem.attribute( "value" );
double value = strValue.toDouble();
if ( value < 0 || value > 10000 || value != static_cast< int >( value ) )
if ( value < 0 || value > 10000 || !qgsDoubleNear( value, static_cast< int >( value ) ) )
{
QgsDebugMsg( QString( "forcing SingleBandPseudoColor value = %1" ).arg( value ) );
drawingStyle = "SingleBandPseudoColor";
@@ -80,7 +80,7 @@ void QgsProviderRegistry::init()

#if defined(Q_OS_WIN) || defined(__CYGWIN__)
mLibraryDirectory.setNameFilters( QStringList( "*.dll" ) );
#elif ANDROID
#elif defined(ANDROID)
mLibraryDirectory.setNameFilters( QStringList( "*provider.so" ) );
#else
mLibraryDirectory.setNameFilters( QStringList( "*.so" ) );
@@ -131,15 +131,15 @@ void QgsProviderRegistry::init()

//MH: Added a further test to detect non-provider plugins linked to provider plugins.
//Only pure provider plugins have 'type' not defined
isprovider_t *hasType = ( isprovider_t * ) cast_to_fptr( myLib.resolve( "type" ) );
isprovider_t *hasType = reinterpret_cast< isprovider_t * >( cast_to_fptr( myLib.resolve( "type" ) ) );
if ( hasType )
{
QgsDebugMsg( QString( "Checking %1: ...invalid (has type method)" ).arg( myLib.fileName() ) );
continue;
}

// get the description and the key for the provider plugin
isprovider_t *isProvider = ( isprovider_t * ) cast_to_fptr( myLib.resolve( "isProvider" ) );
isprovider_t *isProvider = reinterpret_cast< isprovider_t * >( cast_to_fptr( myLib.resolve( "isProvider" ) ) );
if ( !isProvider )
{
QgsDebugMsg( QString( "Checking %1: ...invalid (no isProvider method)" ).arg( myLib.fileName() ) );
@@ -154,14 +154,14 @@ void QgsProviderRegistry::init()
}

// looks like a provider. get the key and description
description_t *pDesc = ( description_t * ) cast_to_fptr( myLib.resolve( "description" ) );
description_t *pDesc = reinterpret_cast< description_t * >( cast_to_fptr( myLib.resolve( "description" ) ) );
if ( !pDesc )
{
QgsDebugMsg( QString( "Checking %1: ...invalid (no description method)" ).arg( myLib.fileName() ) );
continue;
}

providerkey_t *pKey = ( providerkey_t * ) cast_to_fptr( myLib.resolve( "providerKey" ) );
providerkey_t *pKey = reinterpret_cast< providerkey_t * >( cast_to_fptr( myLib.resolve( "providerKey" ) ) );
if ( !pKey )
{
QgsDebugMsg( QString( "Checking %1: ...invalid (no providerKey method)" ).arg( myLib.fileName() ) );
@@ -172,28 +172,28 @@ void QgsProviderRegistry::init()
mProviders[pKey()] = new QgsProviderMetadata( pKey(), pDesc(), myLib.fileName() );

// load database drivers
databaseDrivers_t *pDatabaseDrivers = ( databaseDrivers_t * ) cast_to_fptr( myLib.resolve( "databaseDrivers" ) );
databaseDrivers_t *pDatabaseDrivers = reinterpret_cast< databaseDrivers_t * >( cast_to_fptr( myLib.resolve( "databaseDrivers" ) ) );
if ( pDatabaseDrivers )
{
mDatabaseDrivers = pDatabaseDrivers();
}

// load directory drivers
directoryDrivers_t *pDirectoryDrivers = ( directoryDrivers_t * ) cast_to_fptr( myLib.resolve( "directoryDrivers" ) );
directoryDrivers_t *pDirectoryDrivers = reinterpret_cast< directoryDrivers_t * >( cast_to_fptr( myLib.resolve( "directoryDrivers" ) ) );
if ( pDirectoryDrivers )
{
mDirectoryDrivers = pDirectoryDrivers();
}

// load protocol drivers
protocolDrivers_t *pProtocolDrivers = ( protocolDrivers_t * ) cast_to_fptr( myLib.resolve( "protocolDrivers" ) );
protocolDrivers_t *pProtocolDrivers = reinterpret_cast< protocolDrivers_t * >( cast_to_fptr( myLib.resolve( "protocolDrivers" ) ) );
if ( pProtocolDrivers )
{
mProtocolDrivers = pProtocolDrivers();
}

// now get vector file filters, if any
fileVectorFilters_t *pFileVectorFilters = ( fileVectorFilters_t * ) cast_to_fptr( myLib.resolve( "fileVectorFilters" ) );
fileVectorFilters_t *pFileVectorFilters = reinterpret_cast< fileVectorFilters_t * >( cast_to_fptr( myLib.resolve( "fileVectorFilters" ) ) );
if ( pFileVectorFilters )
{
QString fileVectorFilters = pFileVectorFilters();
@@ -207,7 +207,7 @@ void QgsProviderRegistry::init()
// now get raster file filters, if any
// this replaces deprecated QgsRasterLayer::buildSupportedRasterFileFilter
buildsupportedrasterfilefilter_t *pBuild =
( buildsupportedrasterfilefilter_t * ) cast_to_fptr( myLib.resolve( "buildSupportedRasterFileFilter" ) );
reinterpret_cast< buildsupportedrasterfilefilter_t * >( cast_to_fptr( myLib.resolve( "buildSupportedRasterFileFilter" ) ) );
if ( pBuild )
{
QString fileRasterFilters;
@@ -239,7 +239,7 @@ void QgsProviderRegistry::clean()
QLibrary myLib( lib );
if ( myLib.isLoaded() )
{
cleanupProviderFunction_t* cleanupFunc = ( cleanupProviderFunction_t* ) cast_to_fptr( myLib.resolve( "cleanupProvider" ) );
cleanupProviderFunction_t* cleanupFunc = reinterpret_cast< cleanupProviderFunction_t* >( cast_to_fptr( myLib.resolve( "cleanupProvider" ) ) );
if ( cleanupFunc )
cleanupFunc();
}
@@ -384,7 +384,7 @@ QgsDataProvider *QgsProviderRegistry::provider( QString const & providerKey, QSt
return nullptr;
}

classFactoryFunction_t *classFactory = ( classFactoryFunction_t * ) cast_to_fptr( myLib.resolve( "classFactory" ) );
classFactoryFunction_t *classFactory = reinterpret_cast< classFactoryFunction_t * >( cast_to_fptr( myLib.resolve( "classFactory" ) ) );
if ( !classFactory )
{
QgsDebugMsg( QString( "Failed to load %1: no classFactory method" ).arg( lib ) );
@@ -411,7 +411,7 @@ int QgsProviderRegistry::providerCapabilities( const QString &providerKey ) cons
return QgsDataProvider::NoDataCapabilities;
}

dataCapabilities_t * dataCapabilities = ( dataCapabilities_t * ) cast_to_fptr( library->resolve( "dataCapabilities" ) );
dataCapabilities_t * dataCapabilities = reinterpret_cast< dataCapabilities_t *>( cast_to_fptr( library->resolve( "dataCapabilities" ) ) );
if ( !dataCapabilities )
{
return QgsDataProvider::NoDataCapabilities;
@@ -427,7 +427,7 @@ QWidget* QgsProviderRegistry::selectWidget( const QString & providerKey,
QWidget * parent, const Qt::WindowFlags& fl )
{
selectFactoryFunction_t * selectFactory =
( selectFactoryFunction_t * ) cast_to_fptr( function( providerKey, "selectWidget" ) );
reinterpret_cast< selectFactoryFunction_t * >( cast_to_fptr( function( providerKey, "selectWidget" ) ) );

if ( !selectFactory )
return nullptr;
@@ -495,7 +495,7 @@ void QgsProviderRegistry::registerGuis( QWidget *parent )

Q_FOREACH ( const QString &provider, providerList() )
{
registerGui_function *registerGui = ( registerGui_function * ) cast_to_fptr( function( provider, "registerGui" ) );
registerGui_function *registerGui = reinterpret_cast< registerGui_function * >( cast_to_fptr( function( provider, "registerGui" ) ) );

if ( !registerGui )
continue;
@@ -221,9 +221,9 @@ bool QgsRectangle::isEmpty() const
bool QgsRectangle::isNull() const
{
// rectangle created QgsRectangle() or with rect.setMinimal() ?
return ( xmin == 0 && xmax == 0 && ymin == 0 && ymax == 0 ) ||
( xmin == std::numeric_limits<double>::max() && ymin == std::numeric_limits<double>::max() &&
xmax == -std::numeric_limits<double>::max() && ymax == -std::numeric_limits<double>::max() );
return ( qgsDoubleNear( xmin, 0.0 ) && qgsDoubleNear( xmax, 0.0 ) && qgsDoubleNear( ymin, 0.0 ) && qgsDoubleNear( ymax, 0.0 ) ) ||
( qgsDoubleNear( xmin, std::numeric_limits<double>::max() ) && qgsDoubleNear( ymin, std::numeric_limits<double>::max() ) &&
qgsDoubleNear( xmax, -std::numeric_limits<double>::max() ) && qgsDoubleNear( ymax, -std::numeric_limits<double>::max() ) );
}

QString QgsRectangle::asWktCoordinates() const
@@ -252,7 +252,7 @@ QString QgsRectangle::asWktPolygon() const
//! returns a QRectF with same coordinates.
QRectF QgsRectangle::toRectF() const
{
return QRectF(( qreal )xmin, ( qreal )ymin, ( qreal )xmax - xmin, ( qreal )ymax - ymin );
return QRectF( static_cast< qreal >( xmin ), static_cast< qreal >( ymin ), static_cast< qreal >( xmax - xmin ), static_cast< qreal >( ymax - ymin ) );
}

// Return a string representation of the rectangle with automatic or high precision
@@ -321,10 +321,10 @@ QString QgsRectangle::asPolygon() const

bool QgsRectangle::operator==( const QgsRectangle & r1 ) const
{
return r1.xMaximum() == xMaximum() &&
r1.xMinimum() == xMinimum() &&
r1.yMaximum() == yMaximum() &&
r1.yMinimum() == yMinimum();
return qgsDoubleNear( r1.xMaximum(), xMaximum() ) &&
qgsDoubleNear( r1.xMinimum(), xMinimum() ) &&
qgsDoubleNear( r1.yMaximum(), yMaximum() ) &&
qgsDoubleNear( r1.yMinimum(), yMinimum() );
}


0 comments on commit 2eb95f0

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