Close streams immediately when we finish using them

This commit is contained in:
Oren Hurvitz
2014-06-01 17:39:11 +03:00
parent b81187db5a
commit 99ac770abb
34 changed files with 426 additions and 485 deletions

View File

@@ -280,7 +280,7 @@ namespace OpenSim.Region.Framework.Scenes
if (!m_selected)
{
StopTimer();
m_serializedPosition = m_group.AbsolutePosition;
m_serializedPosition = m_group.AbsolutePosition;
}
}
}
@@ -308,10 +308,11 @@ namespace OpenSim.Region.Framework.Scenes
try
{
MemoryStream ms = new MemoryStream(data);
BinaryFormatter fmt = new BinaryFormatter();
newMotion = (KeyframeMotion)fmt.Deserialize(ms);
using (MemoryStream ms = new MemoryStream(data))
{
BinaryFormatter fmt = new BinaryFormatter();
newMotion = (KeyframeMotion)fmt.Deserialize(ms);
}
newMotion.m_group = grp;
@@ -345,26 +346,26 @@ namespace OpenSim.Region.Framework.Scenes
return;
m_group = grp;
m_scene = grp.Scene;
m_scene = grp.Scene;
Vector3 grppos = grp.AbsolutePosition;
Vector3 offset = grppos - m_serializedPosition;
Vector3 offset = grppos - m_serializedPosition;
// avoid doing it more than once
// current this will happen dragging a prim to other region
m_serializedPosition = grppos;
m_basePosition += offset;
m_nextPosition += offset;
m_currentFrame.StartPosition += offset;
m_currentFrame.Position += offset;
m_currentFrame.Position += offset;
for (int i = 0; i < m_frames.Count; i++)
{
Keyframe k = m_frames[i];
k.StartPosition += offset;
k.Position += offset;
m_frames[i]=k;
m_frames[i]=k;
}
if (m_running)
@@ -527,7 +528,7 @@ namespace OpenSim.Region.Framework.Scenes
{
k.Position = pos;
// k.Velocity = Vector3.Zero;
}
}
k.StartRotation = rot;
if (k.Rotation.HasValue)
@@ -764,19 +765,22 @@ namespace OpenSim.Region.Framework.Scenes
public Byte[] Serialize()
{
StopTimer();
MemoryStream ms = new MemoryStream();
BinaryFormatter fmt = new BinaryFormatter();
SceneObjectGroup tmp = m_group;
m_group = null;
if (!m_selected && tmp != null)
m_serializedPosition = tmp.AbsolutePosition;
fmt.Serialize(ms, this);
m_group = tmp;
if (m_running && !m_waitingCrossing)
StartTimer();
m_group = null;
if (!m_selected && tmp != null)
m_serializedPosition = tmp.AbsolutePosition;
return ms.ToArray();
using (MemoryStream ms = new MemoryStream())
{
BinaryFormatter fmt = new BinaryFormatter();
fmt.Serialize(ms, this);
m_group = tmp;
if (m_running && !m_waitingCrossing)
StartTimer();
return ms.ToArray();
}
}
public void StartCrossingCheck()