diff --git a/src/Aircraft/replay.cxx b/src/Aircraft/replay.cxx index d938122cc..0b3b36e45 100644 --- a/src/Aircraft/replay.cxx +++ b/src/Aircraft/replay.cxx @@ -1992,7 +1992,7 @@ void FGReplay::call_indexContinuousRecording(void* ref, const void* data, size_t * Actual data and signal configuration is not read when in "Preview" mode. */ bool -FGReplay::loadTape(const SGPath& Filename, bool Preview, SGPropertyNode& MetaMeta, simgear::HTTP::FileRequest* filerequest) +FGReplay::loadTape(const SGPath& Filename, bool Preview, SGPropertyNode& MetaMeta, simgear::HTTP::FileRequestRef filerequest) { SG_LOG(SG_SYSTEMS, SG_DEBUG, "loading Preview=" << Preview << " Filename=" << Filename); @@ -2026,14 +2026,16 @@ FGReplay::loadTape(const SGPath& Filename, bool Preview, SGPropertyNode& MetaMet m_num_frames_multiplayer = 0; m_continuous_indexing_in.open(Filename.str()); m_continuous_indexing_pos = in.tellg(); - SG_LOG(SG_SYSTEMS, SG_DEBUG, "filerequest=" << filerequest); + SG_LOG(SG_SYSTEMS, SG_DEBUG, "filerequest=" << filerequest.get()); // Make an in-memory index of the recording. if (filerequest) { - // Always call indexContinuousRecording once in case there is - // nothing to download. - indexContinuousRecording(nullptr, 1 /*Zero means EOF. */); - filerequest->setCallback(call_indexContinuousRecording, this); + filerequest->setCallback( + [this](const void* data, size_t numbytes) + { + indexContinuousRecording(data, numbytes); + } + ); } else { indexContinuousRecording(nullptr, 0); diff --git a/src/Aircraft/replay.hxx b/src/Aircraft/replay.hxx index 8d307136f..fe7545057 100644 --- a/src/Aircraft/replay.hxx +++ b/src/Aircraft/replay.hxx @@ -133,7 +133,7 @@ public: const SGPath& Filename, bool Preview, SGPropertyNode& MetaMeta, - simgear::HTTP::FileRequest* filerequest=nullptr + simgear::HTTP::FileRequestRef filerequest=nullptr ); // Attempts to load Continuous recording header properties into diff --git a/src/Main/options.cxx b/src/Main/options.cxx index 72fecd81a..ecd938bae 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -1595,7 +1595,7 @@ fgOptLoadTape(const char* arg) // struct DelayedTapeLoader : SGPropertyChangeListener { - DelayedTapeLoader( const char * tape, simgear::HTTP::FileRequest* filerequest) : + DelayedTapeLoader( const char * tape, simgear::HTTP::FileRequestRef filerequest) : _tape(SGPath::fromUtf8(tape)), _filerequest(filerequest) { @@ -1627,11 +1627,11 @@ fgOptLoadTape(const char* arg) } private: SGPath _tape; - simgear::HTTP::FileRequest* _filerequest; + simgear::HTTP::FileRequestRef _filerequest; }; SGPropertyNode_ptr properties(new SGPropertyNode); - simgear::HTTP::FileRequest* filerequest = nullptr; + simgear::HTTP::FileRequestRef filerequest; std::string path = urlToLocalPath(arg); if (path == "") { @@ -1653,7 +1653,7 @@ fgOptLoadTape(const char* arg) const char* url = arg; FGHTTPClient* http = globals->add_new_subsystem(); http->init(); - filerequest = new simgear::HTTP::FileRequest(url, path, true /*append*/); + filerequest.reset(new simgear::HTTP::FileRequest(url, path, true /*append*/)); long max_download_speed = fgGetLong("/sim/replay/download-max-bytes-per-sec"); if (max_download_speed != 0) { // Can be useful to limite download speed for testing background