Skip to content

Commit ffb9d0c

Browse files
committedDec 17, 2017
Guard QgsLayoutExporter against nullptrs
1 parent 9ab813f commit ffb9d0c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
 

‎src/core/layout/qgslayoutexporter.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ void QgsLayoutExporter::renderRegion( QPainter *painter, const QRectF &region )
166166

167167
QImage QgsLayoutExporter::renderRegionToImage( const QRectF &region, QSize imageSize, double dpi ) const
168168
{
169+
if ( !mLayout )
170+
return QImage();
171+
169172
LayoutContextPreviewSettingRestorer restorer( mLayout );
170173
( void )restorer;
171174

@@ -231,6 +234,9 @@ class LayoutContextSettingsRestorer
231234

232235
QgsLayoutExporter::ExportResult QgsLayoutExporter::exportToImage( const QString &filePath, const QgsLayoutExporter::ImageExportSettings &s )
233236
{
237+
if ( !mLayout )
238+
return PrintError;
239+
234240
ImageExportSettings settings = s;
235241
if ( settings.dpi <= 0 )
236242
settings.dpi = mLayout->context().dpi();
@@ -330,6 +336,9 @@ QgsLayoutExporter::ExportResult QgsLayoutExporter::exportToImage( const QString
330336

331337
QgsLayoutExporter::ExportResult QgsLayoutExporter::exportToPdf( const QString &filePath, const QgsLayoutExporter::PdfExportSettings &s )
332338
{
339+
if ( !mLayout )
340+
return PrintError;
341+
333342
PdfExportSettings settings = s;
334343
if ( settings.dpi <= 0 )
335344
settings.dpi = mLayout->context().dpi();
@@ -597,6 +606,9 @@ void QgsLayoutExporter::writeWorldFile( const QString &worldFileName, double a,
597606

598607
bool QgsLayoutExporter::georeferenceOutput( const QString &file, QgsLayoutItemMap *map, const QRectF &exportRegion, double dpi ) const
599608
{
609+
if ( !mLayout )
610+
return false;
611+
600612
if ( !map )
601613
map = mLayout->referenceMap();
602614

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

631643
void QgsLayoutExporter::computeWorldFileParameters( double &a, double &b, double &c, double &d, double &e, double &f, double dpi ) const
632644
{
645+
if ( !mLayout )
646+
return;
647+
633648
QgsLayoutItemMap *map = mLayout->referenceMap();
634649
if ( !map )
635650
{
@@ -646,6 +661,9 @@ void QgsLayoutExporter::computeWorldFileParameters( double &a, double &b, double
646661

647662
void QgsLayoutExporter::computeWorldFileParameters( const QRectF &exportRegion, double &a, double &b, double &c, double &d, double &e, double &f, double dpi ) const
648663
{
664+
if ( !mLayout )
665+
return;
666+
649667
// World file parameters : affine transformation parameters from pixel coordinates to map coordinates
650668
QgsLayoutItemMap *map = mLayout->referenceMap();
651669
if ( !map )

0 commit comments

Comments
 (0)
Please sign in to comment.