| 859 | | |
|---|
| 860 | | /* Remove the object from the table |
|---|
| 861 | | * so that it cannot be encountered by vlc_object_get() */ |
|---|
| 862 | | libvlc_global_data_t *p_libvlc_global = vlc_global(); |
|---|
| 863 | | int i_index; |
|---|
| 864 | | |
|---|
| 865 | | i_index = FindIndex( p_this, p_libvlc_global->pp_objects, |
|---|
| 866 | | p_libvlc_global->i_objects ); |
|---|
| 867 | | REMOVE_ELEM( p_libvlc_global->pp_objects, |
|---|
| 868 | | p_libvlc_global->i_objects, i_index ); |
|---|
| 869 | | |
|---|
| 870 | | /* Detach from parent to protect against FIND_CHILDREN */ |
|---|
| 871 | | if (p_this->p_parent) |
|---|
| 872 | | vlc_object_detach_unlocked (p_this); |
|---|
| 873 | | /* Detach from children to protect against FIND_PARENT */ |
|---|
| 874 | | for (int i = 0; i < p_this->i_children; i++) |
|---|
| 875 | | p_this->pp_children[i]->p_parent = NULL; |
|---|
| | 861 | /* Take the spin again. Note that another thread may have yielded the |
|---|
| | 862 | * object in the (very short) mean time. */ |
|---|
| | 863 | vlc_spin_lock( &internals->ref_spin ); |
|---|
| | 864 | b_should_destroy = --internals->i_refcount == 0; |
|---|
| | 865 | vlc_spin_unlock( &internals->ref_spin ); |
|---|
| | 866 | |
|---|
| | 867 | if( b_should_destroy ) |
|---|
| | 868 | { |
|---|
| | 869 | /* Remove the object from the table |
|---|
| | 870 | * so that it cannot be encountered by vlc_object_get() */ |
|---|
| | 871 | libvlc_global_data_t *p_libvlc_global = vlc_global(); |
|---|
| | 872 | int i_index; |
|---|
| | 873 | |
|---|
| | 874 | i_index = FindIndex( p_this, p_libvlc_global->pp_objects, |
|---|
| | 875 | p_libvlc_global->i_objects ); |
|---|
| | 876 | REMOVE_ELEM( p_libvlc_global->pp_objects, |
|---|
| | 877 | p_libvlc_global->i_objects, i_index ); |
|---|
| | 878 | |
|---|
| | 879 | /* Detach from parent to protect against FIND_CHILDREN */ |
|---|
| | 880 | if (p_this->p_parent) |
|---|
| | 881 | vlc_object_detach_unlocked (p_this); |
|---|
| | 882 | /* Detach from children to protect against FIND_PARENT */ |
|---|
| | 883 | for (int i = 0; i < p_this->i_children; i++) |
|---|
| | 884 | p_this->pp_children[i]->p_parent = NULL; |
|---|
| | 885 | } |
|---|