diff options
Diffstat (limited to 'OpenSim/Region/CoreModules')
8 files changed, 44 insertions, 59 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs index 732781a..5cdcab9 100644 --- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs +++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs | |||
@@ -231,7 +231,11 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender | |||
231 | { | 231 | { |
232 | try | 232 | try |
233 | { | 233 | { |
234 | List<int> layerStarts = CSJ2K.J2kImage.GetLayerBoundaries(new MemoryStream(j2kData)); | 234 | List<int> layerStarts; |
235 | using (MemoryStream ms = new MemoryStream(j2kData)) | ||
236 | { | ||
237 | layerStarts = CSJ2K.J2kImage.GetLayerBoundaries(ms); | ||
238 | } | ||
235 | 239 | ||
236 | if (layerStarts != null && layerStarts.Count > 0) | 240 | if (layerStarts != null && layerStarts.Count > 0) |
237 | { | 241 | { |
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs index ff87ece..13512a2 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
@@ -289,18 +289,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
289 | 289 | ||
290 | rootElement.AppendChild(result); | 290 | rootElement.AppendChild(result); |
291 | 291 | ||
292 | return DocToBytes(doc); | 292 | return Util.DocToBytes(doc); |
293 | } | ||
294 | |||
295 | private byte[] DocToBytes(XmlDocument doc) | ||
296 | { | ||
297 | MemoryStream ms = new MemoryStream(); | ||
298 | XmlTextWriter xw = new XmlTextWriter(ms, null); | ||
299 | xw.Formatting = Formatting.Indented; | ||
300 | doc.WriteTo(xw); | ||
301 | xw.Flush(); | ||
302 | |||
303 | return ms.ToArray(); | ||
304 | } | 293 | } |
305 | 294 | ||
306 | #endregion | 295 | #endregion |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index e9c6fb6..c8056d4 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | |||
@@ -918,17 +918,18 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
918 | { | 918 | { |
919 | ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>(); | 919 | ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>(); |
920 | 920 | ||
921 | MemoryStream ms = new MemoryStream(data); | 921 | using (MemoryStream ms = new MemoryStream(data)) |
922 | if (m_displacement != Vector3.Zero || m_rotation != 0f) | ||
923 | { | 922 | { |
924 | Vector2 rotationCenter = new Vector2(m_rotationCenter.X, m_rotationCenter.Y); | 923 | if (m_displacement != Vector3.Zero || m_rotation != 0f) |
925 | terrainModule.LoadFromStream(terrainPath, m_displacement, m_rotation, rotationCenter, ms); | 924 | { |
926 | } | 925 | Vector2 rotationCenter = new Vector2(m_rotationCenter.X, m_rotationCenter.Y); |
927 | else | 926 | terrainModule.LoadFromStream(terrainPath, m_displacement, m_rotation, rotationCenter, ms); |
928 | { | 927 | } |
929 | terrainModule.LoadFromStream(terrainPath, ms); | 928 | else |
929 | { | ||
930 | terrainModule.LoadFromStream(terrainPath, ms); | ||
931 | } | ||
930 | } | 932 | } |
931 | ms.Close(); | ||
932 | 933 | ||
933 | m_log.DebugFormat("[ARCHIVER]: Restored terrain {0}", terrainPath); | 934 | m_log.DebugFormat("[ARCHIVER]: Restored terrain {0}", terrainPath); |
934 | 935 | ||
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs index 136a16e..448147a 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs | |||
@@ -569,10 +569,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
569 | string terrainPath = String.Format("{0}{1}{2}.r32", | 569 | string terrainPath = String.Format("{0}{1}{2}.r32", |
570 | regionDir, ArchiveConstants.TERRAINS_PATH, scene.RegionInfo.RegionName); | 570 | regionDir, ArchiveConstants.TERRAINS_PATH, scene.RegionInfo.RegionName); |
571 | 571 | ||
572 | MemoryStream ms = new MemoryStream(); | 572 | using (MemoryStream ms = new MemoryStream()) |
573 | scene.RequestModuleInterface<ITerrainModule>().SaveToStream(terrainPath, ms); | 573 | { |
574 | m_archiveWriter.WriteFile(terrainPath, ms.ToArray()); | 574 | scene.RequestModuleInterface<ITerrainModule>().SaveToStream(terrainPath, ms); |
575 | ms.Close(); | 575 | m_archiveWriter.WriteFile(terrainPath, ms.ToArray()); |
576 | } | ||
576 | 577 | ||
577 | m_log.InfoFormat("[ARCHIVER]: Adding scene objects to archive."); | 578 | m_log.InfoFormat("[ARCHIVER]: Adding scene objects to archive."); |
578 | 579 | ||
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index eecc478..b417198 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs | |||
@@ -1116,9 +1116,8 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
1116 | { | 1116 | { |
1117 | try | 1117 | try |
1118 | { | 1118 | { |
1119 | MemoryStream terrainStream = new MemoryStream(terrainData); | 1119 | using (MemoryStream terrainStream = new MemoryStream(terrainData)) |
1120 | terr.LoadFromStream(filename, terrainStream); | 1120 | terr.LoadFromStream(filename, terrainStream); |
1121 | terrainStream.Close(); | ||
1122 | 1121 | ||
1123 | FileInfo x = new FileInfo(filename); | 1122 | FileInfo x = new FileInfo(filename); |
1124 | remoteClient.SendAlertMessage("Your terrain was loaded as a " + x.Extension + " file. It may take a few moments to appear."); | 1123 | remoteClient.SendAlertMessage("Your terrain was loaded as a " + x.Extension + " file. It may take a few moments to appear."); |
diff --git a/OpenSim/Region/CoreModules/World/Estate/XEstateRequestHandler.cs b/OpenSim/Region/CoreModules/World/Estate/XEstateRequestHandler.cs index 2366767..ec5af2b 100644 --- a/OpenSim/Region/CoreModules/World/Estate/XEstateRequestHandler.cs +++ b/OpenSim/Region/CoreModules/World/Estate/XEstateRequestHandler.cs | |||
@@ -281,18 +281,8 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
281 | 281 | ||
282 | rootElement.AppendChild(result); | 282 | rootElement.AppendChild(result); |
283 | 283 | ||
284 | return DocToBytes(doc); | 284 | return Util.DocToBytes(doc); |
285 | } | 285 | } |
286 | 286 | ||
287 | private byte[] DocToBytes(XmlDocument doc) | ||
288 | { | ||
289 | MemoryStream ms = new MemoryStream(); | ||
290 | XmlTextWriter xw = new XmlTextWriter(ms, null); | ||
291 | xw.Formatting = Formatting.Indented; | ||
292 | doc.WriteTo(xw); | ||
293 | xw.Flush(); | ||
294 | |||
295 | return ms.ToArray(); | ||
296 | } | ||
297 | } | 287 | } |
298 | } | 288 | } |
diff --git a/OpenSim/Region/CoreModules/World/Serialiser/SerialiseObjects.cs b/OpenSim/Region/CoreModules/World/Serialiser/SerialiseObjects.cs index 328fbf0..65f464a 100644 --- a/OpenSim/Region/CoreModules/World/Serialiser/SerialiseObjects.cs +++ b/OpenSim/Region/CoreModules/World/Serialiser/SerialiseObjects.cs | |||
@@ -54,13 +54,14 @@ namespace OpenSim.Region.CoreModules.World.Serialiser | |||
54 | { | 54 | { |
55 | string xmlstream = GetObjectXml(scene); | 55 | string xmlstream = GetObjectXml(scene); |
56 | 56 | ||
57 | MemoryStream stream = ReformatXmlString(xmlstream); | 57 | using (MemoryStream stream = ReformatXmlString(xmlstream)) |
58 | 58 | { | |
59 | stream.Seek(0, SeekOrigin.Begin); | 59 | stream.Seek(0, SeekOrigin.Begin); |
60 | CreateXmlFile(stream, fileName); | 60 | CreateXmlFile(stream, fileName); |
61 | 61 | ||
62 | stream.Seek(0, SeekOrigin.Begin); | 62 | stream.Seek(0, SeekOrigin.Begin); |
63 | CreateCompressedXmlFile(stream, fileName); | 63 | CreateCompressedXmlFile(stream, fileName); |
64 | } | ||
64 | } | 65 | } |
65 | 66 | ||
66 | private static MemoryStream ReformatXmlString(string xmlstream) | 67 | private static MemoryStream ReformatXmlString(string xmlstream) |
@@ -112,13 +113,16 @@ namespace OpenSim.Region.CoreModules.World.Serialiser | |||
112 | { | 113 | { |
113 | #region GZip Compressed Version | 114 | #region GZip Compressed Version |
114 | 115 | ||
115 | FileStream objectsFileCompressed = new FileStream(fileName + ".gzs", FileMode.Create); | 116 | using (FileStream objectsFileCompressed = new FileStream(fileName + ".gzs", FileMode.Create)) |
116 | MemoryStream gzipMSStream = new MemoryStream(); | 117 | using (MemoryStream gzipMSStream = new MemoryStream()) |
117 | GZipStream gzipStream = new GZipStream(gzipMSStream, CompressionMode.Compress); | 118 | { |
118 | xmlStream.WriteTo(gzipStream); | 119 | using (GZipStream gzipStream = new GZipStream(gzipMSStream, CompressionMode.Compress, true)) |
119 | gzipMSStream.WriteTo(objectsFileCompressed); | 120 | { |
120 | objectsFileCompressed.Flush(); | 121 | xmlStream.WriteTo(gzipStream); |
121 | objectsFileCompressed.Close(); | 122 | } |
123 | |||
124 | gzipMSStream.WriteTo(objectsFileCompressed); | ||
125 | } | ||
122 | 126 | ||
123 | #endregion | 127 | #endregion |
124 | } | 128 | } |
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 2d28d6e..995e297 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | |||
@@ -1145,7 +1145,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1145 | 1145 | ||
1146 | if (myMapImageJPEG.Length == 0) | 1146 | if (myMapImageJPEG.Length == 0) |
1147 | { | 1147 | { |
1148 | MemoryStream imgstream = new MemoryStream(); | 1148 | MemoryStream imgstream = null; |
1149 | Bitmap mapTexture = new Bitmap(1,1); | 1149 | Bitmap mapTexture = new Bitmap(1,1); |
1150 | ManagedImage managedImage; | 1150 | ManagedImage managedImage; |
1151 | Image image = (Image)mapTexture; | 1151 | Image image = (Image)mapTexture; |
@@ -1192,10 +1192,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1192 | image.Dispose(); | 1192 | image.Dispose(); |
1193 | 1193 | ||
1194 | if (imgstream != null) | 1194 | if (imgstream != null) |
1195 | { | ||
1196 | imgstream.Close(); | ||
1197 | imgstream.Dispose(); | 1195 | imgstream.Dispose(); |
1198 | } | ||
1199 | } | 1196 | } |
1200 | } | 1197 | } |
1201 | else | 1198 | else |
@@ -1639,4 +1636,4 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1639 | public uint itemtype; | 1636 | public uint itemtype; |
1640 | public ulong regionhandle; | 1637 | public ulong regionhandle; |
1641 | } | 1638 | } |
1642 | } \ No newline at end of file | 1639 | } |