diff options
author | Oren Hurvitz | 2014-06-01 17:39:11 +0300 |
---|---|---|
committer | Oren Hurvitz | 2014-07-21 08:30:03 +0100 |
commit | 99ac770abbe3a95887c4b10c82f3985aa878eeef (patch) | |
tree | 8c946dab083dd50a352f3861415eca43185d8d95 /OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | |
parent | Set "[Terrain]SendTerrainUpdatesByViewDistance=true" by default. (diff) | |
download | opensim-SC_OLD-99ac770abbe3a95887c4b10c82f3985aa878eeef.zip opensim-SC_OLD-99ac770abbe3a95887c4b10c82f3985aa878eeef.tar.gz opensim-SC_OLD-99ac770abbe3a95887c4b10c82f3985aa878eeef.tar.bz2 opensim-SC_OLD-99ac770abbe3a95887c4b10c82f3985aa878eeef.tar.xz |
Close streams immediately when we finish using them
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/KeyframeMotion.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 2d489ea..b4a171f 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | |||
@@ -280,7 +280,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
280 | if (!m_selected) | 280 | if (!m_selected) |
281 | { | 281 | { |
282 | StopTimer(); | 282 | StopTimer(); |
283 | m_serializedPosition = m_group.AbsolutePosition; | 283 | m_serializedPosition = m_group.AbsolutePosition; |
284 | } | 284 | } |
285 | } | 285 | } |
286 | } | 286 | } |
@@ -308,10 +308,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
308 | 308 | ||
309 | try | 309 | try |
310 | { | 310 | { |
311 | MemoryStream ms = new MemoryStream(data); | 311 | using (MemoryStream ms = new MemoryStream(data)) |
312 | BinaryFormatter fmt = new BinaryFormatter(); | 312 | { |
313 | 313 | BinaryFormatter fmt = new BinaryFormatter(); | |
314 | newMotion = (KeyframeMotion)fmt.Deserialize(ms); | 314 | newMotion = (KeyframeMotion)fmt.Deserialize(ms); |
315 | } | ||
315 | 316 | ||
316 | newMotion.m_group = grp; | 317 | newMotion.m_group = grp; |
317 | 318 | ||
@@ -345,26 +346,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
345 | return; | 346 | return; |
346 | 347 | ||
347 | m_group = grp; | 348 | m_group = grp; |
348 | m_scene = grp.Scene; | 349 | m_scene = grp.Scene; |
349 | 350 | ||
350 | Vector3 grppos = grp.AbsolutePosition; | 351 | Vector3 grppos = grp.AbsolutePosition; |
351 | Vector3 offset = grppos - m_serializedPosition; | 352 | Vector3 offset = grppos - m_serializedPosition; |
352 | // avoid doing it more than once | 353 | // avoid doing it more than once |
353 | // current this will happen dragging a prim to other region | 354 | // current this will happen dragging a prim to other region |
354 | m_serializedPosition = grppos; | 355 | m_serializedPosition = grppos; |
355 | 356 | ||
356 | m_basePosition += offset; | 357 | m_basePosition += offset; |
357 | m_nextPosition += offset; | 358 | m_nextPosition += offset; |
358 | 359 | ||
359 | m_currentFrame.StartPosition += offset; | 360 | m_currentFrame.StartPosition += offset; |
360 | m_currentFrame.Position += offset; | 361 | m_currentFrame.Position += offset; |
361 | 362 | ||
362 | for (int i = 0; i < m_frames.Count; i++) | 363 | for (int i = 0; i < m_frames.Count; i++) |
363 | { | 364 | { |
364 | Keyframe k = m_frames[i]; | 365 | Keyframe k = m_frames[i]; |
365 | k.StartPosition += offset; | 366 | k.StartPosition += offset; |
366 | k.Position += offset; | 367 | k.Position += offset; |
367 | m_frames[i]=k; | 368 | m_frames[i]=k; |
368 | } | 369 | } |
369 | 370 | ||
370 | if (m_running) | 371 | if (m_running) |
@@ -527,7 +528,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
527 | { | 528 | { |
528 | k.Position = pos; | 529 | k.Position = pos; |
529 | // k.Velocity = Vector3.Zero; | 530 | // k.Velocity = Vector3.Zero; |
530 | } | 531 | } |
531 | 532 | ||
532 | k.StartRotation = rot; | 533 | k.StartRotation = rot; |
533 | if (k.Rotation.HasValue) | 534 | if (k.Rotation.HasValue) |
@@ -764,19 +765,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
764 | public Byte[] Serialize() | 765 | public Byte[] Serialize() |
765 | { | 766 | { |
766 | StopTimer(); | 767 | StopTimer(); |
767 | MemoryStream ms = new MemoryStream(); | ||
768 | 768 | ||
769 | BinaryFormatter fmt = new BinaryFormatter(); | ||
770 | SceneObjectGroup tmp = m_group; | 769 | SceneObjectGroup tmp = m_group; |
771 | m_group = null; | 770 | m_group = null; |
772 | if (!m_selected && tmp != null) | 771 | if (!m_selected && tmp != null) |
773 | m_serializedPosition = tmp.AbsolutePosition; | 772 | m_serializedPosition = tmp.AbsolutePosition; |
774 | fmt.Serialize(ms, this); | 773 | |
775 | m_group = tmp; | 774 | using (MemoryStream ms = new MemoryStream()) |
776 | if (m_running && !m_waitingCrossing) | 775 | { |
777 | StartTimer(); | 776 | BinaryFormatter fmt = new BinaryFormatter(); |
777 | fmt.Serialize(ms, this); | ||
778 | m_group = tmp; | ||
779 | if (m_running && !m_waitingCrossing) | ||
780 | StartTimer(); | ||
778 | 781 | ||
779 | return ms.ToArray(); | 782 | return ms.ToArray(); |
783 | } | ||
780 | } | 784 | } |
781 | 785 | ||
782 | public void StartCrossingCheck() | 786 | public void StartCrossingCheck() |