Navigation Menu

Skip to content

Commit

Permalink
fix build on Qt <5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Oct 20, 2018
1 parent dcd3318 commit fcf85a1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/gui/qgsmapcanvas.cpp
Expand Up @@ -691,7 +691,11 @@ QgsRectangle QgsMapCanvas::imageRect( const QImage &img, const QgsMapSettings &m
const QgsMapToPixel &m2p = mapSettings.mapToPixel();
QgsPointXY topLeft = m2p.toMapCoordinates( 0, 0 );
Q_ASSERT( img.devicePixelRatio() == mapSettings.devicePixelRatio() );
#if QT_VERSION >= 0x050600
double res = m2p.mapUnitsPerPixel() / img.devicePixelRatioF();
#else
double res = m2p.mapUnitsPerPixel() / img.devicePixelRatio();
#endif
QgsRectangle rect( topLeft.x(), topLeft.y(), topLeft.x() + img.width()*res, topLeft.y() - img.height()*res );
return rect;
}
Expand Down
11 changes: 10 additions & 1 deletion src/gui/qgsmapcanvasmap.cpp
Expand Up @@ -65,11 +65,20 @@ void QgsMapCanvasMap::paint( QPainter *painter )
int h = std::round( mItemSize.height() ) - 2;

bool scale = false;
if ( mImage.size() != QSize( w, h )*mImage.devicePixelRatioF() )
#if QT_VERSION >= 0x050600
if ( mImage.size() != QSize( w, h ) * mImage.devicePixelRatioF() )
#else
if ( mImage.size() != QSize( w, h ) * mImage.devicePixelRatio() )
#endif
{
QgsDebugMsg( QStringLiteral( "map paint DIFFERENT SIZE: img %1,%2 item %3,%4" )
#if QT_VERSION >= 0x050600
.arg( mImage.width() / mImage.devicePixelRatioF() )
.arg( mImage.height() / mImage.devicePixelRatioF() )
#else
.arg( mImage.width() / mImage.devicePixelRatio() )
.arg( mImage.height() / mImage.devicePixelRatio() )
#endif
.arg( w ).arg( h ) );
// This happens on zoom events when ::paint is called before
// the renderer has completed
Expand Down

0 comments on commit fcf85a1

Please sign in to comment.