summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2014-12-16 11:42:58 +0100
committerKonstantin Käfer <mail@kkaefer.com>2014-12-16 11:42:58 +0100
commit9082a83d6ac2b990db04752a991d97f8d18d4e34 (patch)
tree9b0dee091291ec5cda9c3f56194e86816760bcc9
parent57e6bc6e1b700c12552ed7b18817e9cfc53c834c (diff)
downloadqtlocation-mapboxgl-9082a83d6ac2b990db04752a991d97f8d18d4e34.tar.gz
don't assing nullptr to std::string
-rw-r--r--bin/render.cpp5
-rw-r--r--platform/default/headless_view.cpp46
2 files changed, 29 insertions, 22 deletions
diff --git a/bin/render.cpp b/bin/render.cpp
index 01d32b6db9..feeb4fe3f4 100644
--- a/bin/render.cpp
+++ b/bin/render.cpp
@@ -78,7 +78,10 @@ int main(int argc, char *argv[]) {
// Try to load the token from the environment.
if (!token.size()) {
- token = getenv("MAPBOX_ACCESS_TOKEN");
+ const char *token_ptr = getenv("MAPBOX_ACCESS_TOKEN");
+ if (token_ptr) {
+ token = token_ptr;
+ }
}
// Set access token if present
diff --git a/platform/default/headless_view.cpp b/platform/default/headless_view.cpp
index b0fa60fc12..d85910875f 100644
--- a/platform/default/headless_view.cpp
+++ b/platform/default/headless_view.cpp
@@ -52,32 +52,36 @@ HeadlessView::HeadlessView(std::shared_ptr<HeadlessDisplay> display)
void HeadlessView::loadExtensions() {
make_active();
- const std::string extensions = (char *)MBGL_CHECK_ERROR(glGetString(GL_EXTENSIONS));
+ const char *extension_ptr = (char *)MBGL_CHECK_ERROR(glGetString(GL_EXTENSIONS));
+
+ if (extension_ptr) {
+ const std::string extensions = extension_ptr;
#ifdef MBGL_USE_CGL
- if (extensions.find("GL_APPLE_vertex_array_object") != std::string::npos) {
- gl::BindVertexArray = (gl::PFNGLBINDVERTEXARRAYPROC)CGLGetProcAddress("glBindVertexArrayAPPLE");
- gl::DeleteVertexArrays = (gl::PFNGLDELETEVERTEXARRAYSPROC)CGLGetProcAddress("glDeleteVertexArraysAPPLE");
- gl::GenVertexArrays = (gl::PFNGLGENVERTEXARRAYSPROC)CGLGetProcAddress("glGenVertexArraysAPPLE");
- gl::IsVertexArray = (gl::PFNGLISVERTEXARRAYPROC)CGLGetProcAddress("glIsVertexArrayAPPLE");
- assert(gl::BindVertexArray != nullptr);
- assert(gl::DeleteVertexArrays != nullptr);
- assert(gl::GenVertexArrays != nullptr);
- assert(gl::IsVertexArray != nullptr);
- }
+ if (extensions.find("GL_APPLE_vertex_array_object") != std::string::npos) {
+ gl::BindVertexArray = (gl::PFNGLBINDVERTEXARRAYPROC)CGLGetProcAddress("glBindVertexArrayAPPLE");
+ gl::DeleteVertexArrays = (gl::PFNGLDELETEVERTEXARRAYSPROC)CGLGetProcAddress("glDeleteVertexArraysAPPLE");
+ gl::GenVertexArrays = (gl::PFNGLGENVERTEXARRAYSPROC)CGLGetProcAddress("glGenVertexArraysAPPLE");
+ gl::IsVertexArray = (gl::PFNGLISVERTEXARRAYPROC)CGLGetProcAddress("glIsVertexArrayAPPLE");
+ assert(gl::BindVertexArray != nullptr);
+ assert(gl::DeleteVertexArrays != nullptr);
+ assert(gl::GenVertexArrays != nullptr);
+ assert(gl::IsVertexArray != nullptr);
+ }
#endif
#ifdef MBGL_USE_GLX
- if (extensions.find("GL_ARB_vertex_array_object") != std::string::npos) {
- gl::BindVertexArray = (gl::PFNGLBINDVERTEXARRAYPROC)glXGetProcAddress((const GLubyte *)"glBindVertexArray");
- gl::DeleteVertexArrays = (gl::PFNGLDELETEVERTEXARRAYSPROC)glXGetProcAddress((const GLubyte *)"glDeleteVertexArrays");
- gl::GenVertexArrays = (gl::PFNGLGENVERTEXARRAYSPROC)glXGetProcAddress((const GLubyte *)"glGenVertexArrays");
- gl::IsVertexArray = (gl::PFNGLISVERTEXARRAYPROC)glXGetProcAddress((const GLubyte *)"glIsVertexArray");
- assert(gl::BindVertexArray != nullptr);
- assert(gl::DeleteVertexArrays != nullptr);
- assert(gl::GenVertexArrays != nullptr);
- assert(gl::IsVertexArray != nullptr);
- }
+ if (extensions.find("GL_ARB_vertex_array_object") != std::string::npos) {
+ gl::BindVertexArray = (gl::PFNGLBINDVERTEXARRAYPROC)glXGetProcAddress((const GLubyte *)"glBindVertexArray");
+ gl::DeleteVertexArrays = (gl::PFNGLDELETEVERTEXARRAYSPROC)glXGetProcAddress((const GLubyte *)"glDeleteVertexArrays");
+ gl::GenVertexArrays = (gl::PFNGLGENVERTEXARRAYSPROC)glXGetProcAddress((const GLubyte *)"glGenVertexArrays");
+ gl::IsVertexArray = (gl::PFNGLISVERTEXARRAYPROC)glXGetProcAddress((const GLubyte *)"glIsVertexArray");
+ assert(gl::BindVertexArray != nullptr);
+ assert(gl::DeleteVertexArrays != nullptr);
+ assert(gl::GenVertexArrays != nullptr);
+ assert(gl::IsVertexArray != nullptr);
+ }
#endif
+ }
make_inactive();
}