Skip to content

Commit 9e9a289

Browse files
committed
Fix Coverity UNINTENDED_INTEGER_DIVISION errors
1 parent cb5ef02 commit 9e9a289

10 files changed

+16
-16
lines changed

src/app/qgsdecorationnortharrow.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ void QgsDecorationNorthArrow::render( QPainter * theQPainter )
109109

110110
if ( myQPixmap.load( myFileNameQString ) )
111111
{
112-
double centerXDouble = myQPixmap.width() / 2;
113-
double centerYDouble = myQPixmap.height() / 2;
112+
double centerXDouble = myQPixmap.width() / 2.0;
113+
double centerYDouble = myQPixmap.height() / 2.0;
114114
//save the current canvas rotation
115115
theQPainter->save();
116116
//

src/app/qgsdecorationnortharrowdialog.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ void QgsDecorationNorthArrowDialog::rotatePixmap( int theRotationInt )
9898

9999
myQPainter.setRenderHint( QPainter::SmoothPixmapTransform );
100100

101-
double centerXDouble = myQPixmap.width() / 2;
102-
double centerYDouble = myQPixmap.height() / 2;
101+
double centerXDouble = myQPixmap.width() / 2.0;
102+
double centerYDouble = myQPixmap.height() / 2.0;
103103
//save the current canvas rotation
104104
myQPainter.save();
105105
//myQPainter.translate( (int)centerXDouble, (int)centerYDouble );

src/app/qgsdecorationscalebar.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,12 @@ void QgsDecorationScaleBar::render( QPainter * theQPainter )
149149
//If scale bar is very small reset to 1/4 of the canvas wide
150150
if ( myScaleBarWidth < 30 )
151151
{
152-
myScaleBarWidth = myCanvasWidth / 4; // pixels
152+
myScaleBarWidth = myCanvasWidth / 4.0; // pixels
153153
myActualSize = myScaleBarWidth * myMapUnitsPerPixelDouble; // map units
154154
};
155155

156156
//if scale bar is more than half the canvas wide keep halving until not
157-
while ( myScaleBarWidth > myCanvasWidth / 3 )
157+
while ( myScaleBarWidth > myCanvasWidth / 3.0 )
158158
{
159159
myScaleBarWidth = myScaleBarWidth / 3;
160160
};

src/core/qgspallabeling.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1829,7 +1829,7 @@ void QgsPalLayerSettings::registerFeature( QgsFeature& f, const QgsRenderContext
18291829
return;
18301830
}
18311831

1832-
int divNum = ( int )(( mFeaturesToLabel / maxNumLabels ) + 0.5 );
1832+
int divNum = ( int )((( double )mFeaturesToLabel / maxNumLabels ) + 0.5 );
18331833
if ( divNum && ( mFeatsRegPal == ( int )( mFeatsSendingToPal / divNum ) ) )
18341834
{
18351835
mFeatsSendingToPal += 1;

src/core/raster/qgsrasterlayer.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ QPixmap QgsRasterLayer::previewAsPixmap( QSize size, QColor bgColor )
11001100
double myX = 0.0;
11011101
double myY = 0.0;
11021102
QgsRectangle myExtent = mDataProvider->extent();
1103-
if ( myExtent.width() / myExtent.height() >= myQPixmap.width() / myQPixmap.height() )
1103+
if ( myExtent.width() / myExtent.height() >= ( double )myQPixmap.width() / myQPixmap.height() )
11041104
{
11051105
myMapUnitsPerPixel = myExtent.width() / myQPixmap.width();
11061106
myY = ( myQPixmap.height() - myExtent.height() / myMapUnitsPerPixel ) / 2;
@@ -1152,7 +1152,7 @@ QImage QgsRasterLayer::previewAsImage( QSize size, QColor bgColor, QImage::Forma
11521152
double myX = 0.0;
11531153
double myY = 0.0;
11541154
QgsRectangle myExtent = mDataProvider->extent();
1155-
if ( myExtent.width() / myExtent.height() >= myQImage.width() / myQImage.height() )
1155+
if ( myExtent.width() / myExtent.height() >= ( double )myQImage.width() / myQImage.height() )
11561156
{
11571157
myMapUnitsPerPixel = myExtent.width() / myQImage.width();
11581158
myY = ( myQImage.height() - myExtent.height() / myMapUnitsPerPixel ) / 2;

src/core/raster/qgsrasterprojector.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,8 @@ void QgsRasterProjector::calcSrcRowsCols()
363363
// TODO: different resolution for rows and cols ?
364364

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

370370
double myMinSize = DBL_MAX;

src/core/symbology-ng/qgssymbollayerv2.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ void QgsLineSymbolLayerV2::drawPreviewIcon( QgsSymbolV2RenderContext& context, Q
410410
QPolygonF points;
411411
// we're adding 0.5 to get rid of blurred preview:
412412
// drawing antialiased lines of width 1 at (x,0)-(x,100) creates 2px line
413-
points << QPointF( 0, size.height() / 2 + 0.5 ) << QPointF( size.width(), size.height() / 2 + 0.5 );
413+
points << QPointF( 0, int( size.height() / 2 ) + 0.5 ) << QPointF( size.width(), int( size.height() / 2 ) + 0.5 );
414414

415415
startRender( context );
416416
renderPolyline( points, context );

src/gui/qgsrubberband.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ void QgsRubberBand::paint( QPainter* p )
471471
double x = pt.x();
472472
double y = pt.y();
473473

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

476476
switch ( mIconType )
477477
{

src/gui/qgsscalerangewidget.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ QgsScaleRangeWidget::QgsScaleRangeWidget( QWidget *parent )
4747
mMaximumScaleWidget->setShowCurrentScaleButton( true );
4848
reloadProjectScales();
4949
// add start, add comprehension of scales by settings fake ordered values
50-
mMinimumScaleWidget->setScale( 1 / 100000 );
51-
mMaximumScaleWidget->setScale( 1 / 1000 );
50+
mMinimumScaleWidget->setScale( 1.0 / 100000 );
51+
mMaximumScaleWidget->setScale( 1.0 / 1000 );
5252

5353
mLayout->addWidget( minLbl, 0, 0, 2, 1 );
5454
mLayout->addWidget( mMinimumScaleIconLabel, 0, 1 );

src/gui/qgsvertexmarker.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void QgsVertexMarker::setPenWidth( int width )
5656

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

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

0 commit comments

Comments
 (0)