[Marble-commits] KDE/kdeedu/marble/src/plugins/positionprovider/gpsd

Dennis Nienhüser earthwings at gentoo.org
Wed Apr 28 21:31:13 CEST 2010


SVN commit 1120287 by nienhueser:

Use a non-blocking call to determine if data is available to avoid that the thread cannot be terminated properly when it's blocked by gpsd.
CCBUG: 234311

 M  +7 -5      GpsdConnection.cpp  
 M  +4 -6      GpsdPositionProviderPlugin.cpp  


--- trunk/KDE/kdeedu/marble/src/plugins/positionprovider/gpsd/GpsdConnection.cpp #1120286:1120287
@@ -72,14 +72,15 @@
 
 void GpsdConnection::update()
 {
-    gps_data_t* data = 0;
 #if defined( GPSD_API_MAJOR_VERSION ) && ( GPSD_API_MAJOR_VERSION >= 3 ) && defined( PACKET_SET )
-    while ((data = m_gpsd.poll()) && !(data->set & PACKET_SET)) {
-        data = m_gpsd.poll();
+    if ( m_gpsd.waiting() ) {
+        gps_data_t* data = m_gpsd.poll();
+        if ( data && data->set & PACKET_SET ) {
+            emit gpsdInfo( *data );
     }
+    }
 #else
-    data = m_gpsd.query( "o" );
-#endif
+    gps_data_t* data = m_gpsd.query( "o" );
 
     if ( data ) {
         emit gpsdInfo( *data );
@@ -88,6 +89,7 @@
         mDebug() << "Lost connection to gpsd, trying to re-open.";
         initialize();
     }
+#endif
 }
 
 QString GpsdConnection::error() const
--- trunk/KDE/kdeedu/marble/src/plugins/positionprovider/gpsd/GpsdPositionProviderPlugin.cpp #1120286:1120287
@@ -109,16 +109,14 @@
     if (m_thread) {
         m_thread->exit();
         
-        if (!m_thread->wait( 5000 ) )
-        {
-          mDebug() << "Failed to stop GpsdThread, terminating it.";
-          m_thread->terminate();
+        if ( !m_thread->wait( 5000 ) ) {
+            mDebug() << "Failed to stop GpsdThread";
         }
-
-        m_thread->wait();
+        else {
         delete m_thread;
     }
 }
+}
 
 QString GpsdPositionProviderPlugin::error() const
 {


More information about the Marble-commits mailing list