[Marble-commits] KDE/kdeedu/marble/src/plugins/render/osmannotate

Dennis Nienhüser earthwings at gentoo.org
Wed Jul 28 20:55:04 CEST 2010


SVN commit 1156235 by nienhueser:

Make it compile again. Replace qWarning with qDebug. Do not ignore kml parsing errors, otherwise it segfaults.

 M  +18 -13    OsmAnnotatePlugin.cpp  
 M  +6 -6      TextAnnotation.cpp  
 M  +1 -1      TextAnnotation.h  
 M  +1 -1      osm/OsmWayGraphicsItem.cpp  


--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/OsmAnnotatePlugin.cpp #1156234:1156235
@@ -234,7 +234,7 @@
 
         QFile file( filename );
         if ( !file.exists() ) {
-            qWarning( "File does not exist!" );
+            qDebug( "File does not exist!" );
             return;
         }
 
@@ -338,7 +338,7 @@
         file.open( QIODevice::ReadWrite );
 
         if ( !writer.write( &file, document ) ) {
-            qWarning( "Could not write the file." );
+            qDebug( "Could not write the file." );
         }
     }
 }
@@ -357,7 +357,7 @@
 
         QFile file( filename );
         if ( !file.exists() ) {
-            qWarning( "File does not exist!" );
+            qDebug( "File does not exist!" );
             return;
         }
 
@@ -365,21 +365,27 @@
         file.open( QIODevice::ReadOnly );
 
         if ( !parser.read( &file ) ) {
-            qWarning( "Could not parse file!" );
-            //do not quit on a failed read!
-            //return
+            qDebug( "Could not parse file!" );
+            return;
         }
+
         GeoDataDocument* document = dynamic_cast<GeoDataDocument*>(parser.releaseDocument() );
         Q_ASSERT( document );
 
         file.close();
 
-        QVector<GeoDataFeature>::ConstIterator it = document->constBegin();
+        QVector<GeoDataFeature*>::ConstIterator it = document->constBegin();
         for( ; it < document->constEnd(); ++it ) {
             PlacemarkTextAnnotation* annotation = new PlacemarkTextAnnotation();
-            annotation->setName( (*it).name() );
-            annotation->setDescription( (*it).description() );
-            annotation->setCoordinate( GeoDataPlacemark((*it)).coordinate() );
+            annotation->setName( (*it)->name() );
+            annotation->setDescription( (*it)->description() );
+            // annotation->setCoordinate( GeoDataPlacemark((*it)).coordinate() );
+            /** @todo: line above replaced with the four below to have it compile.
+                Needs verification that behavior stays the same */
+            GeoDataPlacemark* placemark = dynamic_cast<GeoDataPlacemark*>(*it);
+            if ( placemark ) {
+                annotation->setCoordinate( placemark->coordinate() );
+            }
             model.append( annotation );
         }
 
@@ -636,9 +642,8 @@
     GeoDataParser parser( GeoData_OSM );
 
     if ( !parser.read( device ) ) {
-        qWarning( "Could not parse file!" );
-        //do not quit on a failed read!
-        //return
+        qDebug( "Could not parse file!" );
+        return;
     }
     QList<GeoGraphicsItem*>* model = parser.releaseModel();
     Q_ASSERT( model );
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/TextAnnotation.cpp #1156234:1156235
@@ -26,18 +26,18 @@
 {
 }
 
-GeoDataPlacemark TextAnnotation::toGeoData() const
+GeoDataPlacemark* TextAnnotation::toGeoData() const
 {
-    GeoDataPlacemark placemark;
+    GeoDataPlacemark* placemark = new GeoDataPlacemark;
 
-    placemark.setName( name() );
-    placemark.setDescription( description() );
+    placemark->setName( name() );
+    placemark->setDescription( description() );
     //allow for HTML in the description
-    placemark.setDescriptionCDATA( true );
+    placemark->setDescriptionCDATA( true );
 
     //FIXME: make this work for all geometries and not just points
 //    FIXME change the geometry() to return a GeoDataGeometry and this won't work
-    placemark.setGeometry( geometry() );
+    placemark->setGeometry( new GeoDataPoint( geometry() ) );
 
     return placemark;
 }
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/TextAnnotation.h #1156234:1156235
@@ -33,7 +33,7 @@
     virtual GeoDataPoint geometry() const = 0;
     virtual void setGeometry( const GeoDataGeometry &geometry ) = 0;
 
-    GeoDataPlacemark toGeoData() const;
+    GeoDataPlacemark* toGeoData() const;
 
 };
 
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/osm/OsmWayGraphicsItem.cpp #1156234:1156235
@@ -25,7 +25,7 @@
         : GeoGraphicsItem()
 {
     m_placemark = new GeoDataPlacemark();
-    m_placemark->setGeometry( GeoDataLineString() );
+    m_placemark->setGeometry( new GeoDataLineString() );
 }
 
 OsmWayGraphicsItem::~OsmWayGraphicsItem()


More information about the Marble-commits mailing list