Fix segfault this-capture GeoJsonSource which may be deleted (#3536)
Co-authored-by: Tim Sylvester <tim@wetdogweather.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -55,13 +55,21 @@ public:
|
||||
|
||||
/// Dynamically cast this source to the given subtype.
|
||||
template <class T>
|
||||
requires(std::is_base_of_v<Source, T>)
|
||||
T* as() {
|
||||
return is<T>() ? reinterpret_cast<T*>(this) : nullptr;
|
||||
if constexpr (std::is_same_v<T, Source>) {
|
||||
return this;
|
||||
}
|
||||
return is<T>() ? static_cast<T*>(this) : nullptr;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
requires(std::is_base_of_v<Source, T>)
|
||||
const T* as() const {
|
||||
return is<T>() ? reinterpret_cast<const T*>(this) : nullptr;
|
||||
if constexpr (std::is_same_v<T, Source>) {
|
||||
return this;
|
||||
}
|
||||
return is<T>() ? static_cast<const T*>(this) : nullptr;
|
||||
}
|
||||
|
||||
SourceType getType() const;
|
||||
|
||||
Reference in New Issue
Block a user