| 133 | } |
| 134 | |
| 135 | void |
| 136 | Exec_Uncompiler::_ProcessUncompilationRuleSet( |
| 137 | const SdfPath &path, |
| 138 | const EsfEditReason editReasons, |
| 139 | Exec_UncompilationRuleSet *const ruleSet) |
| 140 | { |
| 141 | TRACE_FUNCTION(); |
| 142 | |
| 143 | // TODO: Add debug flags to trace the uncompilation process, in which |
| 144 | // logging the path will be helpful. |
| 145 | (void)path; |
| 146 | |
| 147 | Exec_UncompilationRuleSet::iterator ruleSetIter = ruleSet->begin(); |
| 148 | while (ruleSetIter != ruleSet->end()) { |
| 149 | Exec_UncompilationRule &rule = *ruleSetIter; |
| 150 | |
| 151 | // If the target of the rule is no longer valid, then we "garbage |
| 152 | // collect" that rule from the rule set. This can happen if |
| 153 | // uncompilation rules for another path uncompiled the same object in |
| 154 | // the network. |
| 155 | const bool isValidTarget = |
| 156 | std::visit(_IsValidTargetVisitor{*this}, rule.target); |
| 157 | if (!isValidTarget) { |
| 158 | if (editReasons & EsfEditReason::ResyncedObject) { |
| 159 | // If the change is a recursive resync, don't bother erasing the |
| 160 | // individual rule, because the entire rule set is already going |
| 161 | // to be destroyed. |
| 162 | ++ruleSetIter; |
| 163 | } else { |
| 164 | ruleSetIter = ruleSet->erase(ruleSetIter); |
| 165 | } |
| 166 | continue; |
| 167 | } |
| 168 | |
| 169 | // Skip this rule if its edit reasons are not applicable to this change. |
| 170 | if (!(rule.reasons & editReasons)) { |
| 171 | ++ruleSetIter; |
| 172 | continue; |
| 173 | } |
| 174 | |
| 175 | // Uncompile the objects targeted by the rule. |
| 176 | std::visit(_UncompileTargetVisitor{*this}, rule.target); |
| 177 | _didUncompile = true; |
| 178 | |
| 179 | // The rule has triggered and is no longer valid. |
| 180 | ruleSetIter = ruleSet->erase(ruleSetIter); |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | PXR_NAMESPACE_CLOSE_SCOPE |