| 63 | } |
| 64 | |
| 65 | bool cmVariableWatch::VariableAccessed(std::string const& variable, |
| 66 | int access_type, char const* newValue, |
| 67 | cmMakefile const* mf) const |
| 68 | { |
| 69 | auto mit = this->WatchMap.find(variable); |
| 70 | if (mit != this->WatchMap.end()) { |
| 71 | // The strategy here is to copy the list of callbacks, and ignore |
| 72 | // new callbacks that existing ones may add. |
| 73 | std::vector<std::weak_ptr<Pair>> vp(mit->second.begin(), |
| 74 | mit->second.end()); |
| 75 | for (auto& weak_it : vp) { |
| 76 | // In the case where a callback was removed, the weak_ptr will not be |
| 77 | // lockable, and so this ensures we don't attempt to call into freed |
| 78 | // memory |
| 79 | if (auto it = weak_it.lock()) { |
| 80 | it->Method(variable, access_type, it->ClientData, newValue, mf); |
| 81 | } |
| 82 | } |
| 83 | return true; |
| 84 | } |
| 85 | return false; |
| 86 | } |
no test coverage detected