Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[layouts] Avoid a crash when no pages exist in layout
- Loading branch information
|
@@ -164,6 +164,9 @@ int QgsLayoutPageCollection::pageNumberForPoint( QPointF point ) const |
|
|
|
|
|
int QgsLayoutPageCollection::predictPageNumberForPoint( QPointF point ) const |
|
|
{ |
|
|
if ( mPages.empty() ) |
|
|
return 0; |
|
|
|
|
|
int pageNumber = 0; |
|
|
double startNextPageY = 0; |
|
|
Q_FOREACH ( QgsLayoutItemPage *page, mPages ) |
|
|
|
@@ -573,6 +573,9 @@ def testPredictionPageNumberForPoint(self): |
|
|
l = QgsLayout(p) |
|
|
collection = l.pageCollection() |
|
|
|
|
|
# no crash if no pages |
|
|
self.assertEqual(collection.predictPageNumberForPoint(QPointF(1, 1)), 0) |
|
|
|
|
|
# add a page |
|
|
page = QgsLayoutItemPage(l) |
|
|
page.setPageSize(QgsLayoutSize(100, 100)) |
|
|