///////////////////////////////////////////////////////
| 481 | |
| 482 | //////////////////////////////////////////////////////////// |
| 483 | void GlContext::unregisterUnsharedGlObject(std::shared_ptr<void> object) |
| 484 | { |
| 485 | if (const std::lock_guard lock(Impl::getUnsharedGlObjectsMutex()); |
| 486 | const auto unsharedGlObjects = Impl::getWeakUnsharedGlObjects().lock()) |
| 487 | { |
| 488 | // Find the object in unshared objects and remove it if its associated context is currently active |
| 489 | // This will trigger the destructor of the object since shared_ptr |
| 490 | // in unshared objects should be the only one existing |
| 491 | const auto iter = std::find_if(unsharedGlObjects->begin(), |
| 492 | unsharedGlObjects->end(), |
| 493 | [&object](const Impl::UnsharedGlObject& obj) { |
| 494 | return (obj.object == object) && |
| 495 | (obj.contextId == GlContextImpl::CurrentContext::get().id); |
| 496 | }); |
| 497 | |
| 498 | if (iter != unsharedGlObjects->end()) |
| 499 | unsharedGlObjects->erase(iter); |
| 500 | } |
| 501 | } |
| 502 | |
| 503 | |
| 504 | //////////////////////////////////////////////////////////// |