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

Bastian Holst bastianholst at gmx.de
Fri May 21 23:10:27 CEST 2010


SVN commit 1129284 by bholst:

Thread-Safe GeoDataRegion

 M  +4 -0      GeoDataRegion.cpp  
 M  +8 -0      GeoDataRegion_p.h  


--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataRegion.cpp #1129283:1129284
@@ -64,6 +64,7 @@
 
 GeoDataLatLonAltBox& GeoDataRegion::latLonAltBox() const
 {
+    QMutexLocker locker( &d->m_mutex );
     // FIXME: This isn't exactly what a 'const' function should do, is it?
 
     // If the latLonAltBox hasn't been set try to determine it automatically
@@ -101,6 +102,7 @@
 
 void GeoDataRegion::setLatLonAltBox( const GeoDataLatLonAltBox & latLonAltBox )
 {
+    QMutexLocker locker( &d->m_mutex );
     delete d->m_latLonAltBox;
     d->m_latLonAltBox = new GeoDataLatLonAltBox( latLonAltBox );
 }
@@ -108,6 +110,7 @@
 
 GeoDataLod& GeoDataRegion::lod() const
 {
+    QMutexLocker locker( &d->m_mutex );
     // If the lod hasn't been set then return a shared one
     if ( !d->m_lod ) {
         // FIXME: reference a shared object instead
@@ -120,6 +123,7 @@
 
 void GeoDataRegion::setLod( const GeoDataLod & lod )
 {
+    QMutexLocker locker( &d->m_mutex );
     delete d->m_lod;
     d->m_lod = new GeoDataLod( lod );
 }
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataRegion_p.h #1129283:1129284
@@ -15,6 +15,10 @@
 
 #include "GeoDataTypes.h"
 
+//Qt
+#include <QtCore/QMutex>
+#include <QtCore/QMutexLocker>
+
 namespace Marble
 {
 
@@ -56,6 +60,7 @@
 
     ~GeoDataRegionPrivate()
     {
+        QMutexLocker locker( &m_mutex );
         delete m_latLonAltBox;
         delete m_lod;
     }
@@ -68,6 +73,7 @@
 
     GeoDataRegionPrivate &operator=( const GeoDataRegionPrivate other )
     {
+        QMutexLocker locker( &m_mutex );
         m_parent = other.m_parent;
         delete m_latLonAltBox;
         if ( other.m_latLonAltBox ) {
@@ -91,6 +97,8 @@
     GeoDataFeature * m_parent;
     GeoDataLatLonAltBox * m_latLonAltBox;
     GeoDataLod * m_lod;
+
+    QMutex m_mutex;
 };
 
 } // namespace Marble


More information about the Marble-commits mailing list