Skip to content
Permalink
Browse files

fix build on Qt <5.6

  • Loading branch information
jef-n committed Oct 20, 2018
1 parent dcd3318 commit fcf85a199a94aac0fa59a129327d27ff65973ae9
Showing with 14 additions and 1 deletion.
  1. +4 −0 src/gui/qgsmapcanvas.cpp
  2. +10 −1 src/gui/qgsmapcanvasmap.cpp
@@ -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;
}
@@ -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

0 comments on commit fcf85a1

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