@@ -351,21 +351,24 @@ void Game::setupLuaFunctions()
351
351
[this ](const LuaSpineObject &object)
352
352
{
353
353
std::shared_ptr<SpineObject> obj = getObjectById (object);
354
- auto inter = std::static_pointer_cast<InteractableObject>(obj);
355
- obj->setParent (nullptr );
356
- for (auto it = pointer->attatchedObjects .begin (); it != pointer->attatchedObjects .end ();)
354
+ if (obj)
357
355
{
358
- if ((*it) == nullptr || (*it) == obj)
359
- {
360
- it = pointer->attatchedObjects .erase (it);
361
- }
362
- else
356
+ auto inter = std::static_pointer_cast<InteractableObject>(obj);
357
+ obj->setParent (nullptr );
358
+ for (auto it = pointer->attatchedObjects .begin (); it != pointer->attatchedObjects .end ();)
363
359
{
364
- ++it;
360
+ if ((*it) == nullptr || (*it) == obj)
361
+ {
362
+ it = pointer->attatchedObjects .erase (it);
363
+ }
364
+ else
365
+ {
366
+ ++it;
367
+ }
365
368
}
369
+ if (inter)
370
+ inter->registerToDelete ();
366
371
}
367
- if (inter)
368
- inter->registerToDelete ();
369
372
});
370
373
371
374
// / Get all Spine points from this Spine object
@@ -845,12 +848,15 @@ void Game::setupLuaFunctions()
845
848
[this ](const LuaSpineObject &object, const LuaSpinePoint &point_name)
846
849
{
847
850
std::shared_ptr<SpineObject> obj = getObjectById (object);
848
- auto position = obj->getPoint (point_name);
849
- if (position)
851
+ if (obj)
850
852
{
851
- getDialogManager ()->setSpeechBubblePosition (position.value ());
852
- (*lua_state)[" speech_bubble_position_x" ] = position->x ;
853
- (*lua_state)[" speech_bubble_position_y" ] = position->y ;
853
+ auto position = obj->getPoint (point_name);
854
+ if (position)
855
+ {
856
+ getDialogManager ()->setSpeechBubblePosition (position.value ());
857
+ (*lua_state)[" speech_bubble_position_x" ] = position->x ;
858
+ (*lua_state)[" speech_bubble_position_y" ] = position->y ;
859
+ }
854
860
}
855
861
});
856
862
0 commit comments