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

Bastian Holst bastianholst at gmx.de
Mon Aug 17 16:49:19 CEST 2009


SVN commit 1012357 by bholst:

Removed crashes introduced by threads in Marble's weather plugin.


 M  +0 -4      lib/AbstractDataPluginModel.cpp  
 M  +4 -0      plugins/render/photo/PhotoPluginItem.cpp  
 M  +12 -8     plugins/render/weather/BBCParser.cpp  
 M  +2 -1      plugins/render/weather/BBCParser.h  
 M  +4 -2      plugins/render/weather/BBCWeatherService.cpp  
 M  +0 -1      plugins/render/weather/StationListParser.cpp  
 M  +0 -3      plugins/render/weather/StationListParser.h  
 M  +1 -0      plugins/render/wikipedia/WikipediaItem.cpp  
 M  +2 -0      plugins/render/wikipedia/WikipediaModel.cpp  


--- trunk/KDE/kdeedu/marble/src/lib/AbstractDataPluginModel.cpp #1012356:1012357
@@ -454,10 +454,6 @@
                                      fileType );
 
             d->m_downloadingItems.erase( i );
-
-            if ( (*i)->initialized() ) {
-                emit itemsUpdated();
-            }
         }
     }
 }
--- trunk/KDE/kdeedu/marble/src/plugins/render/photo/PhotoPluginItem.cpp #1012356:1012357
@@ -83,6 +83,10 @@
             m_hasCoordinates = true;
         }
     }
+
+    if ( initialized() ) {
+        emit updated();
+    }
 }
 
 void PhotoPluginItem::paint( GeoPainter *painter, ViewportParams *viewport,
--- trunk/KDE/kdeedu/marble/src/plugins/render/weather/BBCParser.cpp #1012356:1012357
@@ -44,6 +44,7 @@
 
 BBCParser::BBCParser()
     : QThread(),
+      m_running( false ),
       m_end( false )
 {
     BBCParser::setupHashes();
@@ -75,9 +76,12 @@
 
     m_schedule.push( entry );
 
-    QMutexLocker locker( &m_runStateMutex );
-    if ( !isRunning() ) {
-        start( QThread::IdlePriority );
+    QMutexLocker locker( &m_runningMutex );
+    if ( !m_running ) {
+        if ( wait( 2 * WAIT_TIME ) ) {
+            m_running = true;
+            start( QThread::IdlePriority );
+        }
     }
 }
 
@@ -85,19 +89,21 @@
 {
     int waitAttempts = WAIT_ATTEMPTS;
     while( 1 ) {
-        m_runStateMutex.lock();
+        m_runningMutex.lock();
         if ( m_schedule.isEmpty() ) {
             waitAttempts--;
             if ( !waitAttempts || m_end ) {
+                m_running = false;
+                m_runningMutex.unlock();
                 break;
             }
             else {
-                m_runStateMutex.unlock();
+                m_runningMutex.unlock();
                 msleep( WAIT_TIME );
             }
         }
         else {
-            m_runStateMutex.unlock();
+            m_runningMutex.unlock();
             ScheduleEntry entry = m_schedule.pop();
 
             QFile file( entry.path );
@@ -121,8 +127,6 @@
             waitAttempts = WAIT_ATTEMPTS;
         }
     }
-
-    m_runStateMutex.unlock();
 }
 
 
--- trunk/KDE/kdeedu/marble/src/plugins/render/weather/BBCParser.h #1012356:1012357
@@ -68,7 +68,8 @@
 
     QList<WeatherData> m_list;
     QStack<ScheduleEntry> m_schedule;
-    QMutex m_runStateMutex;
+    bool m_running;
+    QMutex m_runningMutex;
     bool m_end;
     
     static QHash<QString, WeatherData::WeatherCondition> dayConditions;
--- trunk/KDE/kdeedu/marble/src/plugins/render/weather/BBCWeatherService.cpp #1012356:1012357
@@ -94,9 +94,11 @@
 
     m_parser = new StationListParser( this );
     m_parser->setPath( MarbleDirs::path( "weather/bbc-stations.xml" ) );
-    connect( m_parser, SIGNAL( parsedStationList() ),
+    connect( m_parser, SIGNAL( finished() ),
              this,     SLOT( fetchStationList() ) );
-    m_parser->start( QThread::IdlePriority );
+    if ( m_parser->wait( 100 ) ) {
+        m_parser->start( QThread::IdlePriority );
+    }
 }
 
 #include "BBCWeatherService.moc"
--- trunk/KDE/kdeedu/marble/src/plugins/render/weather/StationListParser.cpp #1012356:1012357
@@ -76,7 +76,6 @@
 
     setDevice( &file );
     read();
-    emit parsedStationList();
 }
 
 void StationListParser::readUnknownElement()
--- trunk/KDE/kdeedu/marble/src/plugins/render/weather/StationListParser.h #1012356:1012357
@@ -37,9 +37,6 @@
 
     void setPath( QString path );
 
-Q_SIGNALS:
-    void parsedStationList();
-
 protected:
     void run();
 
--- trunk/KDE/kdeedu/marble/src/plugins/render/wikipedia/WikipediaItem.cpp #1012356:1012357
@@ -77,6 +77,7 @@
     if ( type == "thumbnail" ) {
         m_thumbnail.load( url );
         updateSize();
+        emit updated();
     }
 }
 
--- trunk/KDE/kdeedu/marble/src/plugins/render/wikipedia/WikipediaModel.cpp #1012356:1012357
@@ -104,6 +104,8 @@
             addItemToList( *it );
         }
     }
+
+    emit itemsUpdated();
 }
 
 #include "WikipediaModel.moc"


More information about the Marble-commits mailing list