Cancel pending style request when loading style JSON (#3709)

Co-authored-by: Tim Sylvester <tim@wetdogweather.com>
This commit is contained in:
Bart Louwers
2025-12-01 10:11:24 +01:00
committed by GitHub
parent 84df7b16fb
commit caa564fd45
7 changed files with 124 additions and 0 deletions

View File

@@ -39,10 +39,15 @@ Style::Impl::Impl(std::shared_ptr<FileSource> fileSource_, float pixelRatio, con
Style::Impl::~Impl() = default;
void Style::Impl::cancelPendingRequest() noexcept {
styleRequest.reset();
}
void Style::Impl::loadJSON(const std::string& json_) {
lastError = nullptr;
observer->onStyleLoading();
cancelPendingRequest();
url.clear();
parse(json_);
}

View File

@@ -45,6 +45,14 @@ public:
void loadJSON(const std::string&);
void loadURL(const std::string&);
/**
* @brief Cancels any pending style request.
*
* This will cancel any in-progress style URL load. Has no effect if no
* style load is in progress.
*/
void cancelPendingRequest() noexcept;
std::string getJSON() const;
std::string getURL() const;