[Marble-commits] branches/KDE/4.3/kdeedu/marble/src/lib/gps
Andrew Manson
g.real.ate at gmail.com
Tue Jul 21 14:37:44 CEST 2009
SVN commit 1000482 by mansona:
fix a crash when using CurrentLocation
M +30 -14 GpsLayer.cpp
M +3 -1 GpsLayer.h
M +6 -0 PositionTracking.cpp
M +2 -0 PositionTracking.h
--- branches/KDE/4.3/kdeedu/marble/src/lib/gps/GpsLayer.cpp #1000481:1000482
@@ -32,11 +32,12 @@
m_tracks = new TrackContainer();*/
// m_files = new QVector<GpxFile*>();
- m_fileModel = fileModel;
+// m_fileModel = fileModel;
// m_gpsTrack = new Track();
m_currentGpx = new GpxFile();
- m_fileModel->addFile( m_currentGpx );
+// m_fileModel->addFile( m_currentGpx );
+ m_ownedGpxFiles.append( m_currentGpx );
m_tracking = new PositionTracking( m_currentGpx );
}
@@ -70,17 +71,29 @@
QRegion temp; // useless variable
updateGps( canvasSize, viewParams, temp);
paintCurrentPosition( painter, canvasSize, viewParams );
+ if( !m_currentGpx ) {
+ m_currentGpx = new GpxFile();
+ m_currentGpx->addTrack( m_tracking->currentGpsTrack() );
+ m_ownedGpxFiles.append( m_currentGpx );
+ }
m_currentGpx->draw( painter, canvasSize, viewParams );
}
- const QVector<GpxFile*> * const allFiles = m_fileModel->allFiles();
- QVector<GpxFile*>::const_iterator it;
- for( it = allFiles->constBegin();
- it != allFiles->constEnd(); ++it ) {
+// const QVector<GpxFile*> * const allFiles = m_fileModel->allFiles();
+ QList<GpxFile*>::const_iterator it;
+ for( it = m_externalGpxFiles.constBegin();
+ it != m_externalGpxFiles.constEnd(); ++it ) {
if( (*it) != m_currentGpx ) {
(*it)->draw( painter, canvasSize, viewParams );
}
}
+
+ for( it = m_ownedGpxFiles.constBegin();
+ it != m_ownedGpxFiles.constEnd(); ++it ) {
+ if( (*it) != m_currentGpx ) {
+ (*it)->draw( painter, canvasSize, viewParams );
+ }
+ }
painter->restore();
}
@@ -100,20 +113,23 @@
{
GpxFile *tempFile = new GpxFile( fileName );
-// QTextStream test(stderr);
-// test << *tempFile;
-
- m_fileModel->addFile( tempFile );
+// m_fileModel->addFile( tempFile );
+ m_ownedGpxFiles.append( tempFile );
}
void GpsLayer::addGpxFile( GpxFile* file )
{
- m_fileModel->addFile( file );
+// m_fileModel->addFile( file );
+ m_externalGpxFiles.append( file );
}
void GpsLayer::clearModel()
{
- delete m_fileModel;
- m_fileModel = 0;
- m_fileModel = new GpxFileModel();
+ while( !m_ownedGpxFiles.isEmpty() ) {
+ GpxFile* file = m_ownedGpxFiles.takeFirst();
+ m_currentGpx = 0;
+ delete file;
+ }
+
+ m_externalGpxFiles.clear();
}
--- branches/KDE/4.3/kdeedu/marble/src/lib/gps/GpsLayer.h #1000481:1000482
@@ -46,7 +46,9 @@
bool updateGps(const QSize &canvasSize, ViewParams *viewParams,
QRegion ®);
- GpxFileModel *m_fileModel;
+ QList<GpxFile*> m_ownedGpxFiles;
+ QList<GpxFile*> m_externalGpxFiles;
+// GpxFileModel *m_fileModel;
PositionTracking* getPositionTracking();
public slots:
virtual void clearModel();
--- branches/KDE/4.3/kdeedu/marble/src/lib/gps/PositionTracking.cpp #1000481:1000482
@@ -201,5 +201,11 @@
}
+Track* PositionTracking::currentGpsTrack()
+{
+ return m_gpsTrack;
+}
+
+
#include "PositionTracking.moc"
--- branches/KDE/4.3/kdeedu/marble/src/lib/gps/PositionTracking.h #1000481:1000482
@@ -82,7 +82,9 @@
const QSize &canvasSize,
ViewParams *viewParams );
+ Track* currentGpsTrack();
+
public slots:
void notifyPosition( GeoDataCoordinates );
More information about the Marble-commits
mailing list