@@ -171,15 +171,12 @@ void SelectEntitiesPrivate::HandleEntitySelection()
171
171
this ->selectedEntitiesID .push_back (this ->selectedEntitiesIDNew [i]);
172
172
173
173
Entity entityId = kNullEntity ;
174
- try
174
+ if (std::holds_alternative<uint64_t >(
175
+ visualToHighLight->UserData (" gazebo-entity" )))
175
176
{
176
177
entityId = std::get<uint64_t >(
177
178
visualToHighLight->UserData (" gazebo-entity" ));
178
179
}
179
- catch (std::bad_variant_access &_e)
180
- {
181
- // It's ok to get here
182
- }
183
180
184
181
this ->selectedEntities .push_back (entityId);
185
182
@@ -212,14 +209,10 @@ void SelectEntitiesPrivate::HandleEntitySelection()
212
209
}
213
210
214
211
Entity entityId = kNullEntity ;
215
- try
212
+ if (std::holds_alternative< uint64_t >(visual-> UserData ( " gazebo-entity " )))
216
213
{
217
214
entityId = std::get<uint64_t >(visual->UserData (" gazebo-entity" ));
218
215
}
219
- catch (std::bad_variant_access &e)
220
- {
221
- // It's ok to get here
222
- }
223
216
224
217
this ->selectionHelper .selectEntity = entityId;
225
218
@@ -243,14 +236,10 @@ void SelectEntitiesPrivate::LowlightNode(const rendering::VisualPtr &_visual)
243
236
Entity entityId = kNullEntity ;
244
237
if (_visual)
245
238
{
246
- try
239
+ if (std::holds_alternative< uint64_t >(_visual-> UserData ( " gazebo-entity " )))
247
240
{
248
241
entityId = std::get<uint64_t >(_visual->UserData (" gazebo-entity" ));
249
242
}
250
- catch (std::bad_variant_access &)
251
- {
252
- // It's ok to get here
253
- }
254
243
}
255
244
if (this ->wireBoxes .find (entityId) != this ->wireBoxes .end ())
256
245
{
@@ -271,14 +260,10 @@ void SelectEntitiesPrivate::HighlightNode(const rendering::VisualPtr &_visual)
271
260
}
272
261
273
262
Entity entityId = kNullEntity ;
274
- try
263
+ if (std::holds_alternative< uint64_t >(_visual-> UserData ( " gazebo-entity " )))
275
264
{
276
265
entityId = std::get<uint64_t >(_visual->UserData (" gazebo-entity" ));
277
266
}
278
- catch (std::bad_variant_access &)
279
- {
280
- // It's ok to get here
281
- }
282
267
283
268
// If the entity is not found in the existing map, create a wire box
284
269
auto wireBoxIt = this ->wireBoxes .find (entityId);
@@ -358,14 +343,11 @@ void SelectEntitiesPrivate::SetSelectedEntity(
358
343
359
344
if (topLevelVisual)
360
345
{
361
- try
346
+ if (std::holds_alternative<uint64_t >(
347
+ topLevelVisual->UserData (" gazebo-entity" )))
362
348
{
363
349
entityId = std::get<uint64_t >(topLevelVisual->UserData (" gazebo-entity" ));
364
350
}
365
- catch (std::bad_variant_access &)
366
- {
367
- // It's ok to get here
368
- }
369
351
}
370
352
371
353
if (entityId == kNullEntity )
@@ -544,14 +526,11 @@ bool SelectEntities::eventFilter(QObject *_obj, QEvent *_event)
544
526
auto visual = this ->dataPtr ->scene ->VisualByIndex (i);
545
527
546
528
Entity entityId = kNullEntity ;
547
- try
529
+ if (std::holds_alternative<uint64_t >(
530
+ visual->UserData (" gazebo-entity" )))
548
531
{
549
532
entityId = std::get<uint64_t >(visual->UserData (" gazebo-entity" ));
550
533
}
551
- catch (std::bad_variant_access &)
552
- {
553
- // It's ok to get here
554
- }
555
534
556
535
if (entityId == entity)
557
536
{
0 commit comments