MCPcopy Create free account
hub / github.com/GNOME/gjs / weak_pointer_was_finalized

Method weak_pointer_was_finalized

gi/object.cpp:2468–2494  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2466}
2467
2468bool ObjectInstance::weak_pointer_was_finalized(JSTracer* trc) {
2469 if (has_wrapper() && !wrapper_is_rooted()) {
2470 bool toggle_down_queued, toggle_up_queued;
2471
2472 auto toggle_queue = ToggleQueue::get_default();
2473 std::tie(toggle_down_queued, toggle_up_queued) =
2474 toggle_queue->is_queued(this);
2475
2476 if (!toggle_down_queued && toggle_up_queued)
2477 return false;
2478
2479 if (!update_after_gc(trc))
2480 return false;
2481
2482 if (toggle_down_queued)
2483 toggle_queue->cancel(this);
2484
2485 /* Ouch, the JS object is dead already. Disassociate the GObject and
2486 * hope the GObject dies too. (Remove it from the weak pointer list
2487 * first, since the disassociation may also cause it to be erased.)
2488 */
2489 debug_lifecycle("Found GObject weak pointer whose JS wrapper is about "
2490 "to be finalized");
2491 return true;
2492 }
2493 return false;
2494}
2495
2496/**
2497 * ObjectInstance::ensure_weak_pointer_callback:

Callers 1

Calls 2

is_queuedMethod · 0.80
cancelMethod · 0.45

Tested by

no test coverage detected