[QGIS Commit] r12267 - trunk/qgis/src/core

svn_qgis at osgeo.org svn_qgis at osgeo.org
Fri Nov 27 04:25:46 EST 2009


Author: mhugent
Date: 2009-11-27 04:25:44 -0500 (Fri, 27 Nov 2009)
New Revision: 12267

Modified:
   trunk/qgis/src/core/qgspalobjectpositionmanager.cpp
Log:
better test for 0 objects when using pal diagram placement

Modified: trunk/qgis/src/core/qgspalobjectpositionmanager.cpp
===================================================================
--- trunk/qgis/src/core/qgspalobjectpositionmanager.cpp	2009-11-27 07:56:15 UTC (rev 12266)
+++ trunk/qgis/src/core/qgspalobjectpositionmanager.cpp	2009-11-27 09:25:44 UTC (rev 12267)
@@ -142,11 +142,22 @@
   //pal geometry that the current label object refers to
   QgsPALGeometry* referredGeometry = 0;
   QgsOverlayObject* referredOverlayObject = 0;
+  pal::FeaturePart* referredPart = 0;
 
   std::list<pal::LabelPosition*>::iterator labelIt = resultLabelList->begin();
   for ( ; labelIt != resultLabelList->end(); ++labelIt )
   {
-    referredGeometry = dynamic_cast<QgsPALGeometry*>(( *labelIt )->getFeaturePart()->getUserGeometry() );
+    if ( !*labelIt )
+    {
+      continue;
+    }
+
+    referredPart = ( *labelIt )->getFeaturePart();
+    if ( !referredPart )
+    {
+      continue;
+    }
+    referredGeometry = dynamic_cast<QgsPALGeometry*>( referredPart->getUserGeometry() );
     if ( !referredGeometry )
     {
       continue;
@@ -160,8 +171,8 @@
     pal::LabelPosition* lp = *labelIt;
 
     //QGIS takes the coordinates of the middle points
-    double x = (lp->getX( 0 ) + lp->getX( 1 ) + lp->getX( 2 ) + lp->getX( 3 ) ) / 4;
-    double y = (lp->getY( 0 ) + lp->getY( 1 ) + lp->getY( 2 ) + lp->getY( 3 ) ) / 4;
+    double x = ( lp->getX( 0 ) + lp->getX( 1 ) + lp->getX( 2 ) + lp->getX( 3 ) ) / 4;
+    double y = ( lp->getY( 0 ) + lp->getY( 1 ) + lp->getY( 2 ) + lp->getY( 3 ) ) / 4;
     referredOverlayObject->addPosition( QgsPoint( x, y ) );
   }
 



More information about the QGIS-commit mailing list