Fix crashes that were reported when using object right click menu
Menu entries that cannot work when an object vanishes will gracefully fail.
This commit is contained in:
@@ -9479,12 +9479,27 @@ class ListStartIM : public view_listener_t
|
|||||||
};
|
};
|
||||||
|
|
||||||
const LLVector3d& get_av_pos(const LLUUID& id);
|
const LLVector3d& get_av_pos(const LLUUID& id);
|
||||||
|
const LLVector3d get_obj_pos(const LLUUID& id)
|
||||||
|
{
|
||||||
|
if (const auto& obj = gObjectList.findObject(id))
|
||||||
|
return obj->getPositionGlobal();
|
||||||
|
return LLVector3d::zero;
|
||||||
|
}
|
||||||
|
static const LLVector3d get_active_pos()
|
||||||
|
{
|
||||||
|
const auto& id = LFIDBearer::getActiveSelectedID();
|
||||||
|
if (LFIDBearer::getActiveType() == LFIDBearer::OBJECT)
|
||||||
|
return get_obj_pos(id);
|
||||||
|
return get_av_pos(id);
|
||||||
|
}
|
||||||
|
|
||||||
class ListTeleportTo : public view_listener_t
|
class ListTeleportTo : public view_listener_t
|
||||||
{
|
{
|
||||||
bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
|
bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
|
||||||
{
|
{
|
||||||
const auto& id = LFIDBearer::getActiveSelectedID();
|
const auto& pos = get_active_pos();
|
||||||
gAgent.teleportViaLocation(LFIDBearer::getActiveType() == LFIDBearer::OBJECT ? gObjectList.findObject(id)->getPositionGlobal() : get_av_pos(id));
|
if (!pos.isExactlyZero())
|
||||||
|
gAgent.teleportViaLocation(pos);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -9601,8 +9616,9 @@ class ListGoTo : public view_listener_t
|
|||||||
{
|
{
|
||||||
bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
|
bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
|
||||||
{
|
{
|
||||||
auto id = LFIDBearer::getActiveSelectedID();
|
const auto& pos = get_active_pos();
|
||||||
handle_go_to(LFIDBearer::getActiveType() == LFIDBearer::AVATAR ? get_av_pos(id) : gObjectList.findObject(id)->getPositionGlobal());
|
if (!pos.isExactlyZero())
|
||||||
|
handle_go_to(pos);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user