@@ -166,6 +166,9 @@ void QgsLayoutExporter::renderRegion( QPainter *painter, const QRectF ®ion )
166166
167167QImage QgsLayoutExporter::renderRegionToImage ( const QRectF ®ion, 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
232235QgsLayoutExporter::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
331337QgsLayoutExporter::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
598607bool 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
631643void 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
647662void 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