From: Thomas Geymayer Date: Mon, 28 Oct 2013 19:34:11 +0000 (+0100) Subject: HTTP: finish core request before calling any callback. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=7076c9a0ff82a27cbee3f5a9a512b11adc4abd97;p=simgear.git HTTP: finish core request before calling any callback. --- diff --git a/simgear/io/HTTPRequest.cxx b/simgear/io/HTTPRequest.cxx index 6b2a8290..e3980ca1 100644 --- a/simgear/io/HTTPRequest.cxx +++ b/simgear/io/HTTPRequest.cxx @@ -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(); } //------------------------------------------------------------------------------