diff --git a/src/core/layout/qgsabstractreportsection.cpp b/src/core/layout/qgsabstractreportsection.cpp index fce63a7f10f..1b159aa7e6f 100644 --- a/src/core/layout/qgsabstractreportsection.cpp +++ b/src/core/layout/qgsabstractreportsection.cpp @@ -33,6 +33,9 @@ QgsAbstractReportSection::~QgsAbstractReportSection() QgsProject *QgsAbstractReportSection::project() { + if ( QgsReport *report = dynamic_cast< QgsReport * >( this ) ) + return report->layoutProject(); + QgsAbstractReportSection *current = this; while ( QgsAbstractReportSection *parent = current->parentSection() ) { diff --git a/tests/src/python/test_qgsreport.py b/tests/src/python/test_qgsreport.py index b72a0aac9e7..456a521f8ba 100644 --- a/tests/src/python/test_qgsreport.py +++ b/tests/src/python/test_qgsreport.py @@ -37,6 +37,7 @@ class TestQgsReport(unittest.TestCase): r = QgsReport(p) self.assertEqual(r.layoutProject(), p) + self.assertEqual(r.project(), p) r.setHeaderEnabled(True) self.assertTrue(r.headerEnabled())