]> git.mxchange.org Git - flightgear.git/blobdiff - src/Environment/environment_ctrl.cxx
Don't restore initial screen geometry because there is nothing in fg_os* to resize...
[flightgear.git] / src / Environment / environment_ctrl.cxx
index ebfc97e6dfec678f379ce149215059f7bb436dda..b6e8db5864fc0b01564f1b2d4eedb255ae334f0e 100644 (file)
@@ -344,8 +344,7 @@ FGMetarEnvironmentCtrl::FGMetarEnvironmentCtrl ()
 FGMetarEnvironmentCtrl::~FGMetarEnvironmentCtrl ()
 {
 #if defined(ENABLE_THREADS)
-   thread->cancel();
-   thread->join();
+   thread_stop();
 #endif // ENABLE_THREADS
 
    delete env;
@@ -590,8 +589,7 @@ FGMetarEnvironmentCtrl::fetch_data( const string &icao )
 #if defined(ENABLE_THREADS)
         if (_error_count++ >= 3) {
            SG_LOG( SG_GENERAL, SG_WARN, "Stop fetching data permanently.");
-           thread->cancel();
-           thread->join();
+           thread_stop();
         }
 #endif
 
@@ -707,36 +705,25 @@ FGMetarEnvironmentCtrl::update_metar_properties( const FGMetar *m )
 
 
 #if defined(ENABLE_THREADS)
-/**
- * Ensure mutex is unlocked.
- */
 void
-metar_cleanup_handler( void* arg )
+FGMetarEnvironmentCtrl::thread_stop()
 {
-    FGMetarEnvironmentCtrl* fetcher = (FGMetarEnvironmentCtrl*) arg;
-    fetcher->mutex.unlock();
+    request_queue.push( string() );    // ask thread to terminate
+    thread->join();
 }
 
-/**
- *
- */
 void
 FGMetarEnvironmentCtrl::MetarThread::run()
 {
-    pthread_cleanup_push( metar_cleanup_handler, fetcher );
     while ( true )
     {
-        set_cancel( SGThread::CANCEL_DISABLE );
-
         string icao = fetcher->request_queue.pop();
+        if (icao.empty())
+            return;
         SG_LOG( SG_GENERAL, SG_INFO, "Thread: fetch metar data = " << icao );
         FGMetarResult result = fetcher->fetch_data( icao );
-
-        set_cancel( SGThread::CANCEL_DEFERRED );
-
         fetcher->result_queue.push( result );
     }
-    pthread_cleanup_pop(1);
 }
 #endif // ENABLE_THREADS