mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-22 00:06:12 -05:00
Merge pull request #33170 from elpaso/bugfix-gh33168-set-center-crash
Check for empty rect before calling setExtent
This commit is contained in:
commit
bc00621dfd
@ -901,16 +901,20 @@ bool QgsMapCanvas::setReferencedExtent( const QgsReferencedRectangle &extent )
|
||||
|
||||
void QgsMapCanvas::setCenter( const QgsPointXY ¢er )
|
||||
{
|
||||
QgsRectangle r = mapSettings().extent();
|
||||
double x = center.x();
|
||||
double y = center.y();
|
||||
setExtent(
|
||||
QgsRectangle(
|
||||
x - r.width() / 2.0, y - r.height() / 2.0,
|
||||
x + r.width() / 2.0, y + r.height() / 2.0
|
||||
),
|
||||
true
|
||||
const QgsRectangle r = mapSettings().extent();
|
||||
const double x = center.x();
|
||||
const double y = center.y();
|
||||
const QgsRectangle rect(
|
||||
x - r.width() / 2.0, y - r.height() / 2.0,
|
||||
x + r.width() / 2.0, y + r.height() / 2.0
|
||||
);
|
||||
if ( ! rect.isEmpty() )
|
||||
{
|
||||
setExtent(
|
||||
rect,
|
||||
true
|
||||
);
|
||||
}
|
||||
} // setCenter
|
||||
|
||||
QgsPointXY QgsMapCanvas::center() const
|
||||
|
Loading…
x
Reference in New Issue
Block a user