When attachments are being saved and deleted for a closing root agent, delete first to avoid a hud race condition with update threads.
If delete doesn't occur first then the update thread can outrace the IsAttachment = false necessary to save attachments and send hud artifacts to other viewers.0.7.3-extended
parent
0ac040d9ca
commit
8dedd91961
|
@ -152,31 +152,40 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
|||
}
|
||||
}
|
||||
|
||||
public void SaveChangedAttachments(IScenePresence sp, bool saveAllScripted)
|
||||
public void DeRezAttachments(IScenePresence sp, bool saveChanged, bool saveAllScripted)
|
||||
{
|
||||
// m_log.DebugFormat("[ATTACHMENTS MODULE]: Saving changed attachments for {0}", sp.Name);
|
||||
|
||||
if (!Enabled)
|
||||
return;
|
||||
|
||||
foreach (SceneObjectGroup grp in sp.GetAttachments())
|
||||
// m_log.DebugFormat("[ATTACHMENTS MODULE]: Saving changed attachments for {0}", sp.Name);
|
||||
|
||||
lock (sp.AttachmentsSyncLock)
|
||||
{
|
||||
grp.IsAttachment = false;
|
||||
grp.AbsolutePosition = grp.RootPart.AttachedPos;
|
||||
UpdateKnownItem(sp, grp, saveAllScripted);
|
||||
grp.IsAttachment = true;
|
||||
foreach (SceneObjectGroup grp in sp.GetAttachments())
|
||||
{
|
||||
grp.Scene.DeleteSceneObject(grp, false);
|
||||
|
||||
if (saveChanged || saveAllScripted)
|
||||
{
|
||||
grp.IsAttachment = false;
|
||||
grp.AbsolutePosition = grp.RootPart.AttachedPos;
|
||||
UpdateKnownItem(sp, grp, saveAllScripted);
|
||||
}
|
||||
}
|
||||
|
||||
sp.ClearAttachments();
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteAttachmentsFromScene(IScenePresence sp, bool silent)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[ATTACHMENTS MODULE]: Deleting attachments from scene {0} for {1}, silent = {2}",
|
||||
// m_scene.RegionInfo.RegionName, sp.Name, silent);
|
||||
|
||||
if (!Enabled)
|
||||
return;
|
||||
|
||||
// m_log.DebugFormat(
|
||||
// "[ATTACHMENTS MODULE]: Deleting attachments from scene {0} for {1}, silent = {2}",
|
||||
// m_scene.RegionInfo.RegionName, sp.Name, silent);
|
||||
|
||||
foreach (SceneObjectGroup sop in sp.GetAttachments())
|
||||
{
|
||||
sop.Scene.DeleteSceneObject(sop, silent);
|
||||
|
|
|
@ -43,10 +43,15 @@ namespace OpenSim.Region.Framework.Interfaces
|
|||
void RezAttachments(IScenePresence sp);
|
||||
|
||||
/// <summary>
|
||||
/// Save the attachments that have change on this presence.
|
||||
/// Derez the attachements for a scene presence that is closing.
|
||||
/// </summary>
|
||||
/// <param name="sp"></param>
|
||||
void SaveChangedAttachments(IScenePresence sp, bool saveAllScripted);
|
||||
/// <remarks>
|
||||
/// Attachment changes are saved.
|
||||
/// </remarks>
|
||||
/// <param name="sp">The presence closing</param>
|
||||
/// <param name="saveChanged">Save changed attachments.</param>
|
||||
/// <param name="saveAllScripted">Save attachments with scripts even if they haven't changed.</para>
|
||||
void DeRezAttachments(IScenePresence sp, bool saveChanged, bool saveAllScripted);
|
||||
|
||||
/// <summary>
|
||||
/// Delete all the presence's attachments from the scene
|
||||
|
|
|
@ -499,6 +499,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
public IAttachmentsModule AttachmentsModule { get; set; }
|
||||
public IEntityTransferModule EntityTransferModule { get; private set; }
|
||||
public IAgentAssetTransactions AgentTransactionsModule { get; private set; }
|
||||
public IUserManagement UserManagementModule { get; private set; }
|
||||
|
||||
public IAvatarFactoryModule AvatarFactory
|
||||
{
|
||||
|
@ -1222,6 +1223,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
EntityTransferModule = RequestModuleInterface<IEntityTransferModule>();
|
||||
m_groupsModule = RequestModuleInterface<IGroupsModule>();
|
||||
AgentTransactionsModule = RequestModuleInterface<IAgentAssetTransactions>();
|
||||
UserManagementModule = RequestModuleInterface<IUserManagement>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -1994,9 +1996,8 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
sceneObject.SetGroup(groupID, null);
|
||||
}
|
||||
|
||||
IUserManagement uman = RequestModuleInterface<IUserManagement>();
|
||||
if (uman != null)
|
||||
sceneObject.RootPart.CreatorIdentification = uman.GetUserUUI(ownerID);
|
||||
if (UserManagementModule != null)
|
||||
sceneObject.RootPart.CreatorIdentification = UserManagementModule.GetUserUUI(ownerID);
|
||||
|
||||
sceneObject.ScheduleGroupForFullUpdate();
|
||||
|
||||
|
@ -2692,14 +2693,13 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
/// <param name="aCircuit"></param>
|
||||
private void CacheUserName(ScenePresence sp, AgentCircuitData aCircuit)
|
||||
{
|
||||
IUserManagement uMan = RequestModuleInterface<IUserManagement>();
|
||||
if (uMan != null)
|
||||
if (UserManagementModule != null)
|
||||
{
|
||||
string first = aCircuit.firstname, last = aCircuit.lastname;
|
||||
|
||||
if (sp.PresenceType == PresenceType.Npc)
|
||||
{
|
||||
uMan.AddUser(aCircuit.AgentID, first, last);
|
||||
UserManagementModule.AddUser(aCircuit.AgentID, first, last);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2718,7 +2718,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
uMan.AddUser(aCircuit.AgentID, first, last, homeURL);
|
||||
UserManagementModule.AddUser(aCircuit.AgentID, first, last, homeURL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3275,17 +3275,19 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
if (!isChildAgent)
|
||||
{
|
||||
if (AttachmentsModule != null && avatar.PresenceType != PresenceType.Npc)
|
||||
if (AttachmentsModule != null)
|
||||
{
|
||||
IUserManagement uMan = RequestModuleInterface<IUserManagement>();
|
||||
// Don't save attachments for HG visitors, it
|
||||
// messes up their inventory. When a HG visitor logs
|
||||
// out on a foreign grid, their attachments will be
|
||||
// reloaded in the state they were in when they left
|
||||
// the home grid. This is best anyway as the visited
|
||||
// grid may use an incompatible script engine.
|
||||
if (uMan == null || uMan.IsLocalGridUser(avatar.UUID))
|
||||
AttachmentsModule.SaveChangedAttachments(avatar, false);
|
||||
bool saveChanged
|
||||
= avatar.PresenceType != PresenceType.Npc
|
||||
&& (UserManagementModule == null || UserManagementModule.IsLocalGridUser(avatar.UUID));
|
||||
|
||||
AttachmentsModule.DeRezAttachments(avatar, saveChanged, false);
|
||||
}
|
||||
|
||||
ForEachClient(
|
||||
|
|
|
@ -3437,9 +3437,6 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
public void Close()
|
||||
{
|
||||
if (!IsChildAgent && m_scene.AttachmentsModule != null)
|
||||
m_scene.AttachmentsModule.DeleteAttachmentsFromScene(this, false);
|
||||
|
||||
// Clear known regions
|
||||
KnownRegions = new Dictionary<ulong, string>();
|
||||
|
||||
|
|
Loading…
Reference in New Issue