Navigation Menu

Skip to content

Commit

Permalink
Guard QgsLayoutExporter against nullptrs
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 17, 2017
1 parent 9ab813f commit ffb9d0c
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/core/layout/qgslayoutexporter.cpp
Expand Up @@ -166,6 +166,9 @@ void QgsLayoutExporter::renderRegion( QPainter *painter, const QRectF &region )

QImage QgsLayoutExporter::renderRegionToImage( const QRectF &region, QSize imageSize, double dpi ) const
{
if ( !mLayout )
return QImage();

LayoutContextPreviewSettingRestorer restorer( mLayout );
( void )restorer;

Expand Down Expand Up @@ -231,6 +234,9 @@ class LayoutContextSettingsRestorer

QgsLayoutExporter::ExportResult QgsLayoutExporter::exportToImage( const QString &filePath, const QgsLayoutExporter::ImageExportSettings &s )
{
if ( !mLayout )
return PrintError;

ImageExportSettings settings = s;
if ( settings.dpi <= 0 )
settings.dpi = mLayout->context().dpi();
Expand Down Expand Up @@ -330,6 +336,9 @@ QgsLayoutExporter::ExportResult QgsLayoutExporter::exportToImage( const QString

QgsLayoutExporter::ExportResult QgsLayoutExporter::exportToPdf( const QString &filePath, const QgsLayoutExporter::PdfExportSettings &s )
{
if ( !mLayout )
return PrintError;

PdfExportSettings settings = s;
if ( settings.dpi <= 0 )
settings.dpi = mLayout->context().dpi();
Expand Down Expand Up @@ -597,6 +606,9 @@ void QgsLayoutExporter::writeWorldFile( const QString &worldFileName, double a,

bool QgsLayoutExporter::georeferenceOutput( const QString &file, QgsLayoutItemMap *map, const QRectF &exportRegion, double dpi ) const
{
if ( !mLayout )
return false;

if ( !map )
map = mLayout->referenceMap();

Expand Down Expand Up @@ -630,6 +642,9 @@ bool QgsLayoutExporter::georeferenceOutput( const QString &file, QgsLayoutItemMa

void QgsLayoutExporter::computeWorldFileParameters( double &a, double &b, double &c, double &d, double &e, double &f, double dpi ) const
{
if ( !mLayout )
return;

QgsLayoutItemMap *map = mLayout->referenceMap();
if ( !map )
{
Expand All @@ -646,6 +661,9 @@ void QgsLayoutExporter::computeWorldFileParameters( double &a, double &b, double

void QgsLayoutExporter::computeWorldFileParameters( const QRectF &exportRegion, double &a, double &b, double &c, double &d, double &e, double &f, double dpi ) const
{
if ( !mLayout )
return;

// World file parameters : affine transformation parameters from pixel coordinates to map coordinates
QgsLayoutItemMap *map = mLayout->referenceMap();
if ( !map )
Expand Down

0 comments on commit ffb9d0c

Please sign in to comment.