Skip to content

Commit

Permalink
Use new EcuItem::find method where possible
Browse files Browse the repository at this point in the history
Signed-off-by: Viktor Kopp <vifactor@gmail.com>
  • Loading branch information
vifactor committed Nov 25, 2024
1 parent b4dd859 commit 4ee0541
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5499,26 +5499,16 @@ void MainWindow::on_action_menuDLT_Send_Injection_triggered()

void MainWindow::controlMessage_SetApplication(EcuItem *ecuitem, QString apid, QString appdescription)
{
/* Try to find App */
for(int numapp = 0; numapp < ecuitem->childCount(); numapp++)
{
ApplicationItem * appitem = (ApplicationItem *) ecuitem->child(numapp);

if(appitem->id == apid)
{
appitem->description = appdescription;
appitem->update();
return;
}
if (auto appitem = ecuitem->find(apid); appitem) {
appitem->description = appdescription;
appitem->update();
} else {
appitem = new ApplicationItem(ecuitem);
appitem->id = apid;
appitem->description = appdescription;
appitem->update();
ecuitem->addChild(appitem);
}

/* No app and no con found */
ApplicationItem* appitem = new ApplicationItem(ecuitem);
appitem->id = apid;
appitem->description = appdescription;
appitem->update();
ecuitem->addChild(appitem);

}

void MainWindow::controlMessage_SetContext(EcuItem *ecuitem, QString apid, QString ctid,QString ctdescription,int log_level,int trace_status)
Expand Down

0 comments on commit 4ee0541

Please sign in to comment.