Skip to content
Permalink
Browse files

Fix Coverity UNINTENDED_INTEGER_DIVISION errors

  • Loading branch information
nyalldawson committed Feb 4, 2015
1 parent cb5ef02 commit 9e9a289615ca84c60abcbe096685434631e77984
@@ -109,8 +109,8 @@ void QgsDecorationNorthArrow::render( QPainter * theQPainter )

if ( myQPixmap.load( myFileNameQString ) )
{
double centerXDouble = myQPixmap.width() / 2;
double centerYDouble = myQPixmap.height() / 2;
double centerXDouble = myQPixmap.width() / 2.0;
double centerYDouble = myQPixmap.height() / 2.0;
//save the current canvas rotation
theQPainter->save();
//
@@ -98,8 +98,8 @@ void QgsDecorationNorthArrowDialog::rotatePixmap( int theRotationInt )

myQPainter.setRenderHint( QPainter::SmoothPixmapTransform );

double centerXDouble = myQPixmap.width() / 2;
double centerYDouble = myQPixmap.height() / 2;
double centerXDouble = myQPixmap.width() / 2.0;
double centerYDouble = myQPixmap.height() / 2.0;
//save the current canvas rotation
myQPainter.save();
//myQPainter.translate( (int)centerXDouble, (int)centerYDouble );
@@ -149,12 +149,12 @@ void QgsDecorationScaleBar::render( QPainter * theQPainter )
//If scale bar is very small reset to 1/4 of the canvas wide
if ( myScaleBarWidth < 30 )
{
myScaleBarWidth = myCanvasWidth / 4; // pixels
myScaleBarWidth = myCanvasWidth / 4.0; // pixels
myActualSize = myScaleBarWidth * myMapUnitsPerPixelDouble; // map units
};

//if scale bar is more than half the canvas wide keep halving until not
while ( myScaleBarWidth > myCanvasWidth / 3 )
while ( myScaleBarWidth > myCanvasWidth / 3.0 )
{
myScaleBarWidth = myScaleBarWidth / 3;
};
@@ -1829,7 +1829,7 @@ void QgsPalLayerSettings::registerFeature( QgsFeature& f, const QgsRenderContext
return;
}

int divNum = ( int )(( mFeaturesToLabel / maxNumLabels ) + 0.5 );
int divNum = ( int )((( double )mFeaturesToLabel / maxNumLabels ) + 0.5 );
if ( divNum && ( mFeatsRegPal == ( int )( mFeatsSendingToPal / divNum ) ) )
{
mFeatsSendingToPal += 1;
@@ -1100,7 +1100,7 @@ QPixmap QgsRasterLayer::previewAsPixmap( QSize size, QColor bgColor )
double myX = 0.0;
double myY = 0.0;
QgsRectangle myExtent = mDataProvider->extent();
if ( myExtent.width() / myExtent.height() >= myQPixmap.width() / myQPixmap.height() )
if ( myExtent.width() / myExtent.height() >= ( double )myQPixmap.width() / myQPixmap.height() )
{
myMapUnitsPerPixel = myExtent.width() / myQPixmap.width();
myY = ( myQPixmap.height() - myExtent.height() / myMapUnitsPerPixel ) / 2;
@@ -1152,7 +1152,7 @@ QImage QgsRasterLayer::previewAsImage( QSize size, QColor bgColor, QImage::Forma
double myX = 0.0;
double myY = 0.0;
QgsRectangle myExtent = mDataProvider->extent();
if ( myExtent.width() / myExtent.height() >= myQImage.width() / myQImage.height() )
if ( myExtent.width() / myExtent.height() >= ( double )myQImage.width() / myQImage.height() )
{
myMapUnitsPerPixel = myExtent.width() / myQImage.width();
myY = ( myQImage.height() - myExtent.height() / myMapUnitsPerPixel ) / 2;
@@ -363,8 +363,8 @@ void QgsRasterProjector::calcSrcRowsCols()
// TODO: different resolution for rows and cols ?

// For now, we take cell sizes projected to source but not to source axes
double myDestColsPerMatrixCell = mDestCols / mCPCols;
double myDestRowsPerMatrixCell = mDestRows / mCPRows;
double myDestColsPerMatrixCell = ( double )mDestCols / mCPCols;
double myDestRowsPerMatrixCell = ( double )mDestRows / mCPRows;
QgsDebugMsg( QString( "myDestColsPerMatrixCell = %1 myDestRowsPerMatrixCell = %2" ).arg( myDestColsPerMatrixCell ).arg( myDestRowsPerMatrixCell ) );

double myMinSize = DBL_MAX;
@@ -410,7 +410,7 @@ void QgsLineSymbolLayerV2::drawPreviewIcon( QgsSymbolV2RenderContext& context, Q
QPolygonF points;
// we're adding 0.5 to get rid of blurred preview:
// drawing antialiased lines of width 1 at (x,0)-(x,100) creates 2px line
points << QPointF( 0, size.height() / 2 + 0.5 ) << QPointF( size.width(), size.height() / 2 + 0.5 );
points << QPointF( 0, int( size.height() / 2 ) + 0.5 ) << QPointF( size.width(), int( size.height() / 2 ) + 0.5 );

startRender( context );
renderPolyline( points, context );
@@ -471,7 +471,7 @@ void QgsRubberBand::paint( QPainter* p )
double x = pt.x();
double y = pt.y();

qreal s = ( mIconSize - 1 ) / 2;
qreal s = ( mIconSize - 1 ) / 2.0;

switch ( mIconType )
{
@@ -47,8 +47,8 @@ QgsScaleRangeWidget::QgsScaleRangeWidget( QWidget *parent )
mMaximumScaleWidget->setShowCurrentScaleButton( true );
reloadProjectScales();
// add start, add comprehension of scales by settings fake ordered values
mMinimumScaleWidget->setScale( 1 / 100000 );
mMaximumScaleWidget->setScale( 1 / 1000 );
mMinimumScaleWidget->setScale( 1.0 / 100000 );
mMaximumScaleWidget->setScale( 1.0 / 1000 );

mLayout->addWidget( minLbl, 0, 0, 2, 1 );
mLayout->addWidget( mMinimumScaleIconLabel, 0, 1 );
@@ -56,7 +56,7 @@ void QgsVertexMarker::setPenWidth( int width )

void QgsVertexMarker::paint( QPainter* p )
{
qreal s = ( mIconSize - 1 ) / 2;
qreal s = ( mIconSize - 1 ) / 2.0;

QPen pen( mColor );
pen.setWidth( mPenWidth );

0 comments on commit 9e9a289

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