summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Tarasov <igor.tarasov@mapbox.com>2019-09-19 16:43:46 +0300
committerIgor Tarasov <igor.tarasov@mapbox.com>2019-09-19 16:43:46 +0300
commit18b4aa0bea64e3314241c986b1c540e6f7afe7f3 (patch)
treeba57fe84f777c7f9397ecd76e88ee97e0a9f41f5
parent7b5264ebd7e9ad639af778d979b9edae6f903980 (diff)
downloadqtlocation-mapboxgl-18b4aa0bea64e3314241c986b1c540e6f7afe7f3.tar.gz
[android] Style source: cleanup, error logging.
-rw-r--r--platform/android/src/style/sources/source.hpp31
1 files changed, 16 insertions, 15 deletions
diff --git a/platform/android/src/style/sources/source.hpp b/platform/android/src/style/sources/source.hpp
index e7fd64c656..4107464b8c 100644
--- a/platform/android/src/style/sources/source.hpp
+++ b/platform/android/src/style/sources/source.hpp
@@ -1,9 +1,12 @@
#pragma once
-#include <mbgl/util/noncopyable.hpp>
#include <mbgl/map/map.hpp>
#include <mbgl/style/source.hpp>
+#include <mbgl/util/noncopyable.hpp>
+#include <mbgl/util/optional.hpp>
+#include <mbgl/util/logging.hpp>
+
#include "../value.hpp"
#include "../../android_renderer_frontend.hpp"
@@ -47,28 +50,26 @@ public:
protected:
- inline void source(std::unique_ptr<mbgl::style::Source> ownedSource) noexcept {
- ownedSource_ = std::move(ownedSource);
+ inline void source(std::unique_ptr<mbgl::style::Source> source) noexcept {
+ ownedSource_ = std::move(source);
}
- inline void source(mbgl::style::Source *coreSource) noexcept {
- nonOwnedSource_ = coreSource->makeWeakPtr();
+ inline void source(mbgl::style::Source *source) noexcept {
+ nonOwnedSource_ = source->makeWeakPtr();
}
- inline mbgl::style::Source* source(jni::JNIEnv& env) {
+ inline mbgl::style::Source* source(optional<jni::JNIEnv&> env = nullopt) {
if (ownedSource_) return ownedSource_.get();
- if (!nonOwnedSource_) {
- jni::ThrowNew(env, jni::FindClass(env, "java/lang/IllegalStateException"),
- "This source got invalidated after the style change");
- }
- return nonOwnedSource_.get();
- }
- inline mbgl::style::Source* source() {
- if (ownedSource_) return ownedSource_.get();
+ const auto msg = "The source got invalidated after the style change";
if (!nonOwnedSource_) {
- return nullptr;
+ if (env) {
+ jni::ThrowNew(*env, jni::FindClass(*env, "java/lang/IllegalStateException"), msg);
+ } else {
+ mbgl::Log::Error(mbgl::Event::JNI, msg);
+ }
}
+
return nonOwnedSource_.get();
}