///////////////////////////////////////////////////////
| 836 | |
| 837 | //////////////////////////////////////////////////////////// |
| 838 | void GlContext::cleanupUnsharedResources() |
| 839 | { |
| 840 | const auto& currentContext = GlContextImpl::CurrentContext::get(); |
| 841 | |
| 842 | // Save the current context so we can restore it later |
| 843 | GlContext* contextToRestore = currentContext.ptr; |
| 844 | |
| 845 | // If this context is already active there is no need to save it |
| 846 | if (m_impl->id == currentContext.id) |
| 847 | contextToRestore = nullptr; |
| 848 | |
| 849 | // Make this context active so resources can be freed |
| 850 | setActive(true); |
| 851 | |
| 852 | { |
| 853 | const std::lock_guard lock(Impl::getUnsharedGlObjectsMutex()); |
| 854 | |
| 855 | // Destroy the unshared objects contained in this context |
| 856 | for (auto iter = m_impl->unsharedGlObjects->begin(); iter != m_impl->unsharedGlObjects->end();) |
| 857 | { |
| 858 | if (iter->contextId == m_impl->id) |
| 859 | { |
| 860 | iter = m_impl->unsharedGlObjects->erase(iter); |
| 861 | } |
| 862 | else |
| 863 | { |
| 864 | ++iter; |
| 865 | } |
| 866 | } |
| 867 | } |
| 868 | |
| 869 | // Make the originally active context active again |
| 870 | if (contextToRestore) |
| 871 | contextToRestore->setActive(true); |
| 872 | } |
| 873 | |
| 874 | |
| 875 | //////////////////////////////////////////////////////////// |