]> git.mxchange.org Git - simgear.git/commitdiff
HTTP: finish core request before calling any callback.
authorThomas Geymayer <tomgey@gmail.com>
Mon, 28 Oct 2013 19:34:11 +0000 (20:34 +0100)
committerThomas Geymayer <tomgey@gmail.com>
Mon, 28 Oct 2013 19:34:11 +0000 (20:34 +0100)
simgear/io/HTTPRequest.cxx

index 6b2a8290a38e36c790d0cdfc64ed8e6612c1bfd2..e3980ca10af3608209ca1e62b324374e0f47a28e 100644 (file)
@@ -304,22 +304,28 @@ void Request::setReadyState(ReadyState state)
   _ready_state = state;
   if( state == DONE )
   {
+    // Finish C++ part of request to ensure everything is finished (for example
+    // files and streams are closed) before calling any callback (possibly using
+    // such files)
+    onDone();
+    onAlways();
+
     if( _cb_done )
       _cb_done(this);
-    onDone();
   }
   else if( state == FAILED )
   {
+    onFail();
+    onAlways();
+
     if( _cb_fail )
       _cb_fail(this);
-    onFail();
   }
   else
     return;
 
   if( _cb_always )
     _cb_always(this);
-  onAlways();
 }
 
 //------------------------------------------------------------------------------