Navigation Menu

Skip to content

Commit

Permalink
Fix crash when saving map image and dpi != 90
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Apr 22, 2017
1 parent d35bd4a commit 1659659
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/app/qgisapp.cpp
Expand Up @@ -92,6 +92,7 @@
#include <QtWinExtras/QWinJumpListCategory>
#endif

Q_GUI_EXPORT extern int qt_defaultDpiX();

//
// Mac OS X Includes
Expand Down Expand Up @@ -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() );
Expand Down
3 changes: 3 additions & 0 deletions src/core/qgsmaprenderertask.cpp
Expand Up @@ -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();
}
Expand Down

0 comments on commit 1659659

Please sign in to comment.