[QGIS Commit] r8268 - trunk/qgis/src/gui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Tue Mar 25 14:55:19 EDT 2008


Author: jef
Date: 2008-03-25 14:55:19 -0400 (Tue, 25 Mar 2008)
New Revision: 8268

Modified:
   trunk/qgis/src/gui/qgsmapcanvas.cpp
Log:
fix #1008

Modified: trunk/qgis/src/gui/qgsmapcanvas.cpp
===================================================================
--- trunk/qgis/src/gui/qgsmapcanvas.cpp	2008-03-25 17:55:34 UTC (rev 8267)
+++ trunk/qgis/src/gui/qgsmapcanvas.cpp	2008-03-25 18:55:19 UTC (rev 8268)
@@ -443,17 +443,23 @@
 void QgsMapCanvas::setExtent(QgsRect const & r)
 {
   if(mDrawing)
-    {
-      return;
-    }
-
-  if (r.isEmpty())
   {
-    QgsDebugMsg("Setting empty extent!");
+    return;
   }
-  
-  QgsRect current = extent();
-  mMapRender->setExtent(r);
+
+  QgsRect current = extent();
+
+  if (r.isEmpty())
+  {
+    QgsDebugMsg("Empty extent - keeping old extent with new center!");
+    QgsRect e( QgsPoint( r.center().x()-current.width()/2.0, r.center().y()-current.height()/2.0 ), 
+               QgsPoint( r.center().x()+current.width()/2.0, r.center().y()+current.height()/2.0 ) );
+    mMapRender->setExtent(e);
+  }
+  else
+  {
+    mMapRender->setExtent(r);
+  }
   emit extentsChanged();
   updateScale();
   if (mMapOverview)



More information about the QGIS-commit mailing list