summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeith Bade <leith@mapbox.com>2015-08-11 09:06:19 +1000
committerLeith Bade <leith@mapbox.com>2015-08-11 09:41:21 +1000
commit9534d6256b370740b59102630dfb517399ca0fc7 (patch)
tree3d6fcc9f47b0d2eddce914a8ce62231952003b71
parentdc11b8132ba7ccc58c280e580526425e7389df86 (diff)
downloadqtlocation-mapboxgl-9534d6256b370740b59102630dfb517399ca0fc7.tar.gz
Fix ThreadContext to check for valid current pointer
-rw-r--r--src/mbgl/util/thread_context.hpp36
1 files changed, 30 insertions, 6 deletions
diff --git a/src/mbgl/util/thread_context.hpp b/src/mbgl/util/thread_context.hpp
index a2be0cd364..626925bdcd 100644
--- a/src/mbgl/util/thread_context.hpp
+++ b/src/mbgl/util/thread_context.hpp
@@ -36,27 +36,51 @@ public:
}
static std::string getName() {
- return current.get()->name;
+ if (current.get() != nullptr) {
+ return current.get()->name;
+ } else {
+ return "Unknown";
+ }
}
static ThreadPriority getPriority() {
- return current.get()->priority;
+ if (current.get() != nullptr) {
+ return current.get()->priority;
+ } else {
+ return ThreadPriority::Regular;
+ }
}
static FileSource* getFileSource() {
- return current.get()->fileSource;
+ if (current.get() != nullptr) {
+ return current.get()->fileSource;
+ } else {
+ return nullptr;
+ }
}
static void setFileSource(FileSource* fileSource) {
- current.get()->fileSource = fileSource;
+ if (current.get() != nullptr) {
+ current.get()->fileSource = fileSource;
+ } else {
+ throw new std::runtime_error("Current thread has no current ThreadContext.");
+ }
}
static GLObjectStore* getGLObjectStore() {
- return current.get()->glObjectStore;
+ if (current.get() != nullptr) {
+ return current.get()->glObjectStore;
+ } else {
+ return nullptr;
+ }
}
static void setGLObjectStore(GLObjectStore* glObjectStore) {
- current.get()->glObjectStore = glObjectStore;
+ if (current.get() != nullptr) {
+ current.get()->glObjectStore = glObjectStore;
+ } else {
+ throw new std::runtime_error("Current thread has no current ThreadContext.");
+ }
}
private: