Skip to content

Commit cde3545

Browse files
authored
Merge pull request cyberbotics#6479 from cyberbotics/sync-master-0dbce8a5c
Merge master into develop
2 parents eaaa8eb + 99b2aba commit cde3545

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

docs/reference/changelog-r2023.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Released on XXX XXth, 2023.
88
- Enabled the launching of MATLAB desktop from the extern launcher ([#6366](https://github.com/cyberbotics/webots/pull/6366)).
99
- Improved overlays visible in Overlays menu by adding all the robots in the menu list ([#6297](https://github.com/cyberbotics/webots/pull/6297)).
1010
- Bug fixes
11+
- Avoided crash and provided better warnings when attempting to access PROTO nodes in a wrong way from the supervisor API ([#6473](https://github.com/cyberbotics/webots/pull/6473)).
1112
- Fixed errors loading template PROTO if the system user name, the project path, or the temporary directory path contains the `\` character ([#6288](https://github.com/cyberbotics/webots/pull/6288)).
1213
- Fixed Webots and libController version comparison not to take revisions into account ([#6315](https://github.com/cyberbotics/webots/pull/6315)).
1314
- Fixed translation, rotation and scale displayed in the Position tab of the Node viewer in the scene tree ([#6309](https://github.com/cyberbotics/webots/pull/6309)).

src/webots/nodes/utils/WbSupervisorUtilities.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,15 @@ WbNode *WbSupervisorUtilities::getProtoParameterNodeInstance(int nodeId, const Q
503503
mRobot->warn(tr("%1: node not found.").arg(functionName));
504504
return NULL;
505505
}
506-
return static_cast<WbBaseNode *>(node)->getFirstFinalizedProtoInstance();
506+
WbBaseNode *proto = static_cast<WbBaseNode *>(node)->getFirstFinalizedProtoInstance();
507+
if (!proto) {
508+
if (node->modelName() != node->nodeModelName())
509+
mRobot->warn(
510+
tr("Cannot get the PROTO instance for node '%1' (derived from '%2').").arg(node->usefulName(), node->nodeModelName()));
511+
else
512+
mRobot->warn(tr("Cannot get the PROTO instance for node '%1'.").arg(node->usefulName()));
513+
}
514+
return proto;
507515
}
508516

509517
void WbSupervisorUtilities::changeSimulationMode(int newMode) {
@@ -594,15 +602,17 @@ void WbSupervisorUtilities::handleMessage(QDataStream &stream) {
594602
stream >> nodeId;
595603
const QString &stateName = readString(stream);
596604
WbNode *const node = getProtoParameterNodeInstance(nodeId, "wb_supervisor_node_load_state()");
597-
node->reset(stateName);
605+
if (node)
606+
node->reset(stateName);
598607
return;
599608
}
600609
case C_SUPERVISOR_NODE_SAVE_STATE: {
601610
unsigned int nodeId;
602611
stream >> nodeId;
603612
const QString &stateName = readString(stream);
604613
WbNode *const node = getProtoParameterNodeInstance(nodeId, "wb_supervisor_node_save_state()");
605-
node->save(stateName);
614+
if (node)
615+
node->save(stateName);
606616
return;
607617
}
608618
case C_SUPERVISOR_NODE_SET_JOINT_POSITION: {

0 commit comments

Comments
 (0)