Cancel pending style request when loading style JSON (#3709)
Co-authored-by: Tim Sylvester <tim@wetdogweather.com>
This commit is contained in:
@@ -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_);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user