it = context_map.find(orig_context);
if (it != context_map.end()) {
- delete it->second;
+ glretrace::Context *currentContext = glretrace::getCurrentContext();
+ if (it->second != currentContext) {
+ // TODO: reference count
+ delete it->second;
+ }
context_map.erase(it);
}
}