Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Fix ThreadContext to check for valid current pointer #2030

Merged
merged 1 commit into from
Aug 18, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 30 additions & 6 deletions src/mbgl/util/thread_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,51 @@ struct ThreadContext {
}

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:
Expand Down