Skip to content
Permalink
Browse files
Fix crash when saving map image and dpi != 90
  • Loading branch information
nyalldawson committed Apr 22, 2017
1 parent d35bd4a commit 16596599dea07576e0c21abb2a2770402c2fc46e
Showing with 6 additions and 2 deletions.
  1. +3 −2 src/app/qgisapp.cpp
  2. +3 −0 src/core/qgsmaprenderertask.cpp
@@ -92,6 +92,7 @@
#include <QtWinExtras/QWinJumpListCategory>
#endif

Q_GUI_EXPORT extern int qt_defaultDpiX();

//
// Mac OS X Includes
@@ -5784,8 +5785,8 @@ void QgisApp::saveMapAsImage()
if ( myFileNameAndFilter.first != QLatin1String( "" ) )
{
//TODO: GUI
int dpi = 90;
QSize size = mMapCanvas->size() * ( dpi / 90 );
int dpi = qt_defaultDpiX();
QSize size = mMapCanvas->size() * ( dpi / qt_defaultDpiX() );

QgsMapSettings ms = QgsMapSettings();
ms.setDestinationCrs( QgsProject::instance()->crs() );
@@ -63,6 +63,9 @@ bool QgsMapRendererTask::run()
return false;
}

img.setDotsPerMeterX( 1000 * mMapSettings.outputDpi() / 25.4 );
img.setDotsPerMeterY( 1000 * mMapSettings.outputDpi() / 25.4 );

tempPainter.reset( new QPainter( &img ) );
destPainter = tempPainter.get();
}

0 comments on commit 1659659

Please sign in to comment.