@@ -166,6 +166,9 @@ void QgsLayoutExporter::renderRegion( QPainter *painter, const QRectF ®ion )
166
166
167
167
QImage QgsLayoutExporter::renderRegionToImage ( const QRectF ®ion, QSize imageSize, double dpi ) const
168
168
{
169
+ if ( !mLayout )
170
+ return QImage ();
171
+
169
172
LayoutContextPreviewSettingRestorer restorer ( mLayout );
170
173
( void )restorer;
171
174
@@ -231,6 +234,9 @@ class LayoutContextSettingsRestorer
231
234
232
235
QgsLayoutExporter::ExportResult QgsLayoutExporter::exportToImage ( const QString &filePath, const QgsLayoutExporter::ImageExportSettings &s )
233
236
{
237
+ if ( !mLayout )
238
+ return PrintError;
239
+
234
240
ImageExportSettings settings = s;
235
241
if ( settings.dpi <= 0 )
236
242
settings.dpi = mLayout ->context ().dpi ();
@@ -330,6 +336,9 @@ QgsLayoutExporter::ExportResult QgsLayoutExporter::exportToImage( const QString
330
336
331
337
QgsLayoutExporter::ExportResult QgsLayoutExporter::exportToPdf ( const QString &filePath, const QgsLayoutExporter::PdfExportSettings &s )
332
338
{
339
+ if ( !mLayout )
340
+ return PrintError;
341
+
333
342
PdfExportSettings settings = s;
334
343
if ( settings.dpi <= 0 )
335
344
settings.dpi = mLayout ->context ().dpi ();
@@ -597,6 +606,9 @@ void QgsLayoutExporter::writeWorldFile( const QString &worldFileName, double a,
597
606
598
607
bool QgsLayoutExporter::georeferenceOutput ( const QString &file, QgsLayoutItemMap *map, const QRectF &exportRegion, double dpi ) const
599
608
{
609
+ if ( !mLayout )
610
+ return false ;
611
+
600
612
if ( !map )
601
613
map = mLayout ->referenceMap ();
602
614
@@ -630,6 +642,9 @@ bool QgsLayoutExporter::georeferenceOutput( const QString &file, QgsLayoutItemMa
630
642
631
643
void QgsLayoutExporter::computeWorldFileParameters ( double &a, double &b, double &c, double &d, double &e, double &f, double dpi ) const
632
644
{
645
+ if ( !mLayout )
646
+ return ;
647
+
633
648
QgsLayoutItemMap *map = mLayout ->referenceMap ();
634
649
if ( !map )
635
650
{
@@ -646,6 +661,9 @@ void QgsLayoutExporter::computeWorldFileParameters( double &a, double &b, double
646
661
647
662
void QgsLayoutExporter::computeWorldFileParameters ( const QRectF &exportRegion, double &a, double &b, double &c, double &d, double &e, double &f, double dpi ) const
648
663
{
664
+ if ( !mLayout )
665
+ return ;
666
+
649
667
// World file parameters : affine transformation parameters from pixel coordinates to map coordinates
650
668
QgsLayoutItemMap *map = mLayout ->referenceMap ();
651
669
if ( !map )
0 commit comments