[Marble-commits] KDE/kdeedu/marble/src/lib

Andrew Manson g.real.ate at gmail.com
Tue Jul 21 02:00:40 CEST 2009


SVN commit 1000183 by mansona:

forward porting r1000182 
fixing a crash and memory leak when switching maps with a gpx file open


 M  +2 -0      AbstractLayer/AbstractLayer.h  
 M  +6 -6      MarbleModel.cpp  
 M  +7 -0      gps/GpsLayer.cpp  
 M  +3 -0      gps/GpsLayer.h  


--- trunk/KDE/kdeedu/marble/src/lib/AbstractLayer/AbstractLayer.h #1000182:1000183
@@ -71,6 +71,8 @@
      */
     void setVisible( bool visible );
 
+    virtual void clearModel() = 0;
+
  public:
     /**
      * @brief Construct this layer with a parent
--- trunk/KDE/kdeedu/marble/src/lib/MarbleModel.cpp #1000182:1000183
@@ -204,18 +204,18 @@
     connect( d->m_placemarkmodel,           SIGNAL( layoutChanged() ),
              d->m_placemarkLayout,          SLOT( requestStyleReset() ) );
 
-    d->m_gpxFileModel = new GpxFileModel( this );
-    d->m_gpsLayer = new GpsLayer( d->m_gpxFileModel );
-
-    connect( d->m_gpxFileModel, SIGNAL( modelChanged() ),
-             this,              SIGNAL( modelChanged() ) );
-
     /*
      * Create FileViewModel
      */
     connect( fileViewModel(), SIGNAL( modelChanged() ),
              this,            SIGNAL( modelChanged() ) );
 
+    d->m_gpxFileModel = new GpxFileModel( this );
+    d->m_gpsLayer = new GpsLayer( d->m_gpxFileModel );
+
+    connect( fileViewModel(), SIGNAL(layoutChanged()),
+             d->m_gpsLayer, SLOT(clearModel() ) );
+
     d->m_dateTime       = new ExtDateTime();
     /* Assume we are dealing with the earth */
     d->m_planet = new Planet( "earth" );
--- trunk/KDE/kdeedu/marble/src/lib/gps/GpsLayer.cpp #1000182:1000183
@@ -110,3 +110,10 @@
 {
     m_fileModel->addFile( file );
 }
+
+void GpsLayer::clearModel()
+{
+    delete m_fileModel;
+    m_fileModel = 0;
+    m_fileModel = new GpxFileModel();
+}
--- trunk/KDE/kdeedu/marble/src/lib/gps/GpsLayer.h #1000182:1000183
@@ -27,6 +27,7 @@
 
 class GpsLayer : public AbstractLayer
 {
+
  public:
     explicit GpsLayer( GpxFileModel *fileModel, QObject *parent =0 );
     ~GpsLayer();
@@ -47,6 +48,8 @@
 
     GpxFileModel        *m_fileModel;
     PositionTracking*   getPositionTracking();
+public slots:
+    virtual void clearModel();
  private:
     Waypoint            *m_currentPosition;
 


More information about the Marble-commits mailing list