MCPcopy Create free account
hub / github.com/RevoSucks/BM64Recomp / destroy_context

Method destroy_context

src/ui/core/ui_context.cpp:251–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

249}
250
251void recompui::destroy_context(ContextId id) {
252 bool existed = false;
253
254 // TODO prevent deletion of a context while its mutex is in use. Second lock on the context's mutex before popping
255 // from the slotmap?
256
257 // Check if the provided id exists.
258 {
259 std::lock_guard lock{ context_state.all_contexts_lock };
260 // Check if the target context is currently open.
261 existed = context_state.all_contexts.has_key(context_slotmap::key{ id.slot_id });
262 }
263
264
265 // Raise an error if the context didn't exist.
266 if (!existed) {
267 context_error(id, ContextErrorType::DestroyInvalidContext);
268 }
269
270 id.open();
271 id.clear_children();
272 id.close();
273
274 // Delete the provided id.
275 {
276 std::lock_guard lock{ context_state.all_contexts_lock };
277 context_state.all_contexts.erase(context_slotmap::key{ id.slot_id });
278 }
279}
280
281void recompui::destroy_all_contexts() {
282 recompui::hide_all_contexts();

Callers

nothing calls this directly

Calls 6

context_errorFunction · 0.85
has_keyMethod · 0.80
openMethod · 0.80
closeMethod · 0.80
clear_childrenMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected