File tree Expand file tree Collapse file tree 1 file changed +13
-9
lines changed Expand file tree Collapse file tree 1 file changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ QgsMapToolZoom::QgsMapToolZoom(QgsMapCanvas* canvas, bool zoomOut)
37
37
38
38
void QgsMapToolZoom::canvasMoveEvent (QMouseEvent * e)
39
39
{
40
- if (e->state () != Qt::LeftButton)
40
+ if ( ! ( e->buttons () & Qt::LeftButton) )
41
41
return ;
42
42
43
43
if (!mDragging )
@@ -54,12 +54,18 @@ void QgsMapToolZoom::canvasMoveEvent(QMouseEvent * e)
54
54
55
55
void QgsMapToolZoom::canvasPressEvent (QMouseEvent * e)
56
56
{
57
+ if (e->button () != Qt::LeftButton)
58
+ return ;
59
+
57
60
mZoomRect .setRect (0 , 0 , 0 , 0 );
58
61
}
59
62
60
63
61
64
void QgsMapToolZoom::canvasReleaseEvent (QMouseEvent * e)
62
65
{
66
+ if (e->button () != Qt::LeftButton)
67
+ return ;
68
+
63
69
if (mDragging )
64
70
{
65
71
mDragging = false ;
@@ -83,6 +89,12 @@ void QgsMapToolZoom::canvasReleaseEvent(QMouseEvent * e)
83
89
r.setYmax (ur.y ());
84
90
r.normalize ();
85
91
92
+ // prevent zooming to an empty extent
93
+ if (r.width () == 0 || r.height () == 0 )
94
+ {
95
+ return ;
96
+ }
97
+
86
98
if (mZoomOut )
87
99
{
88
100
QgsPoint cer = r.center ();
@@ -91,18 +103,10 @@ void QgsMapToolZoom::canvasReleaseEvent(QMouseEvent * e)
91
103
double sf;
92
104
if (mZoomRect .width () > mZoomRect .height ())
93
105
{
94
- if (r.width () == 0 )// prevent nan map extent
95
- {
96
- return ;
97
- }
98
106
sf = extent.width () / r.width ();
99
107
}
100
108
else
101
109
{
102
- if (r.height () == 0 )// prevent nan map extent
103
- {
104
- return ;
105
- }
106
110
sf = extent.height () / r.height ();
107
111
}
108
112
r.expand (sf);
You can’t perform that action at this time.
0 commit comments