Fix crash when saving map image and dpi != 90

This commit is contained in:
Nyall Dawson 2017-04-23 08:34:45 +10:00
parent d35bd4abaa
commit 16596599de
2 changed files with 6 additions and 2 deletions

View File

@ -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() );

View File

@ -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();
}