Skip to content

Commit

Permalink
Followup fix for #11006 (spotted by Nyall - thanks)
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Sep 1, 2014
1 parent d994e0a commit 45d4793
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/core/composer/qgscomposerlegend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,28 @@ void QgsComposerLegend::paint( QPainter* painter, const QStyleOptionGraphicsItem
Q_UNUSED( itemStyle );
Q_UNUSED( pWidget );

if ( !painter )
return;

int dpi = painter->device()->logicalDpiX();
double dotsPerMM = dpi / 25.4;

if ( mComposition )
{
mSettings.setUseAdvancedEffects( mComposition->useAdvancedEffects() );
mSettings.setMapScale( mComposition->mapSettings().scale() );
mSettings.setDpi( painter->device()->logicalDpiX() );
mSettings.setDpi( dpi );
}
if ( mComposerMap )
{
mSettings.setMmPerMapUnit( mComposerMap->mapUnitsToMM() );

if ( !painter )
return;
// use a temporary QgsMapSettings to find out real map scale
QgsMapSettings ms = mComposerMap->composition()->mapSettings();
ms.setOutputSize( QSizeF( mComposerMap->rect().width() * dotsPerMM, mComposerMap->rect().height() * dotsPerMM ).toSize() );
ms.setExtent( *mComposerMap->currentMapExtent() );
ms.setOutputDpi( dpi );
mSettings.setMapScale( ms.scale() );
}

drawBackground( painter );
painter->save();
Expand Down

0 comments on commit 45d4793

Please sign in to comment.