mirror of
https://github.com/moveit/moveit_task_constructor.git
synced 2025-11-04 14:49:57 +08:00
avoid accidental overwrite of InterfaceState
This commit is contained in:
parent
373d7f204f
commit
e368fd9948
@ -156,7 +156,7 @@ public:
|
||||
container_type remove(iterator it);
|
||||
|
||||
/// update state's priority if new priority is smaller and call notify_
|
||||
void updatePriority(InterfaceState &state, const InterfaceState::Priority &priority);
|
||||
void updatePriority(InterfaceState *state, const InterfaceState::Priority &priority);
|
||||
|
||||
private:
|
||||
const NotifyFunction notify_;
|
||||
|
||||
@ -246,12 +246,12 @@ void updateStateCosts(const SerialContainer::solution_container &partial_solutio
|
||||
// here it suffices to update the start state, because the end state is the start state
|
||||
// of the next solution (they are all connected)
|
||||
InterfaceState* state = const_cast<InterfaceState*>(solution->start());
|
||||
if (state->owner()) state->owner()->updatePriority(*state, prio);
|
||||
if (state->owner()) state->owner()->updatePriority(state, prio);
|
||||
}
|
||||
// finally update the end state of the last solution
|
||||
if (partial_solution_path.empty()) return;
|
||||
InterfaceState* state = const_cast<InterfaceState*>(partial_solution_path.back()->end());
|
||||
if (state->owner()) state->owner()->updatePriority(*state, prio);
|
||||
if (state->owner()) state->owner()->updatePriority(state, prio);
|
||||
}
|
||||
|
||||
void SerialContainer::onNewSolution(const SolutionBase ¤t)
|
||||
|
||||
@ -104,13 +104,13 @@ Interface::container_type Interface::remove(iterator it)
|
||||
return result;
|
||||
}
|
||||
|
||||
void Interface::updatePriority(InterfaceState &state, const InterfaceState::Priority& priority)
|
||||
void Interface::updatePriority(InterfaceState *state, const InterfaceState::Priority& priority)
|
||||
{
|
||||
if (priority < state.priority()) {
|
||||
auto it = std::find_if(begin(), end(), [&state](const InterfaceState& other) { return &state == &other; });
|
||||
if (priority < state->priority()) {
|
||||
auto it = std::find_if(begin(), end(), [state](const InterfaceState& other) { return state == &other; });
|
||||
// state should be part of the interface
|
||||
assert(it != end());
|
||||
state.priority_ = priority;
|
||||
state->priority_ = priority;
|
||||
if (notify_) notify_(it, true);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user