Skip to content
Snippets Groups Projects
Commit 594202e2 authored by Peter Albrecht's avatar Peter Albrecht
Browse files

Added guards to check for validity of execution selection

parent 74eeb224
No related branches found
No related tags found
1 merge request!406Refactor skill memory GUI
......@@ -45,12 +45,16 @@ namespace armarx::skills::gui
void
SkillExecutionTreeWidget::stopSelectedExecution()
{
if (!selectionValid())
return;
memory->stopExecution(this->selectedExecution.skillExecutionId);
}
void
SkillExecutionTreeWidget::rerunSkillWithSimilarParams()
{
if (!selectionValid())
return;
// we don't want to hold state in the gui, so we need to get the parameters from memory:
skills::SkillExecutionID currentExecutionId = this->selectedExecution.skillExecutionId;
auto update = memory->getLatestUpdate();
......@@ -67,6 +71,12 @@ namespace armarx::skills::gui
this->memory->startExecutionWithParams(currentExecutionId.skillId, params);
}
inline bool
SkillExecutionTreeWidget::selectionValid()
{
return selectedExecution.skillExecutionId.skillId.skillName != skills::SkillID::UNKNOWN;
}
void
SkillExecutionTreeWidget::stopAllExecutions()
{
......@@ -83,6 +93,14 @@ namespace armarx::skills::gui
}
}
void
SkillExecutionTreeWidget::executionSelectionChanged(QTreeWidgetItem* current,
QTreeWidgetItem* previous)
{
// update internal state
this->selectedExecution.skillExecutionId = *current;
}
void
SkillExecutionTreeWidget::refresh()
{
......
......@@ -57,6 +57,12 @@ namespace armarx::skills::gui
private:
void setupUi();
/**
* @brief Checks the validity of the selected item at run time.
* @return the validity.
*/
bool selectionValid();
SelectedExecution selectedExecution;
};
} // namespace armarx::skills::gui
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment