| 2466 | } |
| 2467 | |
| 2468 | bool 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: |
no test coverage detected