| 104 | } |
| 105 | |
| 106 | void vtkPythonObjectMap::remove(vtkObjectBase* key) |
| 107 | { |
| 108 | iterator i = this->find(key); |
| 109 | if (i != this->end()) |
| 110 | { |
| 111 | // Save the object. The iterator will become invalid if the iterator is |
| 112 | // erased. |
| 113 | vtkObjectBase* obj = i->first; |
| 114 | // Remove it from the map if necessary. |
| 115 | if (!--i->second.second) |
| 116 | { |
| 117 | this->erase(i); |
| 118 | } |
| 119 | // Remove a reference to the object. This must be done *after* removing it |
| 120 | // from the map (if needed) because if there's a callback which reacts when |
| 121 | // the reference is dropped, it might call RemoveObjectFromMap as well. If |
| 122 | // it still exists in the map at that point, this becomes an infinite loop. |
| 123 | obj->Delete(); |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | // Keep weak pointers to VTK objects that python no longer has |
| 128 | // references to. Python keeps the python 'dict' for VTK objects |