#include "GLResource.h"
#include "renderers/utils/GLResourceManager.h"

#include <thread>

namespace carto {

    GLResource::~GLResource() {
    }

    bool GLResource::isValid() const {
        if (auto manager = _manager.lock()) {
            return manager->getGLThreadId() != std::thread::id();
        }
        return false;
    }
      
    GLResource::GLResource(const std::weak_ptr<GLResourceManager>& manager) :
        _manager(manager)
    {
    }

}

#include "GLResource.h"
#include "renderers/utils/GLResourceManager.h"

#include <thread>

namespace carto {

    GLResource::~GLResource() {
    }

    bool GLResource::isValid() const {
        if (_manager.lock()) {
            return true;
        }
        return false;
    }
      
    GLResource::GLResource(const std::weak_ptr<GLResourceManager>& manager) :
        _manager(manager)
    {
    }

}

--- 
+++ 
@@ -9,8 +9,8 @@
     }
 
     bool GLResource::isValid() const {
-        if (_manager.lock()) {
-            return true;
+        if (auto manager = _manager.lock()) {
+            return manager->getGLThreadId() != std::thread::id();
         }
         return false;
     }
Make lost GL context checking more robust, fixes thread race between layers and renderers
