From db418bff2bb6b2676c996e77b260b0977e886f5d Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 11 Nov 2012 19:39:21 -0800 Subject: Fix issues with the DynamicTextureModule and corresponding unit tests. --- .../DynamicTexture/DynamicTextureModule.cs | 10 +++++++ .../Scripting/LoadImageURL/LoadImageURLModule.cs | 31 +++++++++++----------- .../Scripting/VectorRender/VectorRenderModule.cs | 30 ++++++++++----------- OpenSim/Tests/Common/Helpers/SceneHelpers.cs | 10 +++---- 4 files changed, 44 insertions(+), 37 deletions(-) diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs index 9d90517..9d77b19 100644 --- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs @@ -83,6 +83,16 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture /// private Cache m_reuseableDynamicTextures; + /// + /// This constructor is only here because of the Unit Tests... + /// Don't use it. + /// + public DynamicTextureModule() + { + m_reuseableDynamicTextures = new Cache(CacheMedium.Memory, CacheStrategy.Conservative); + m_reuseableDynamicTextures.DefaultTTL = new TimeSpan(24, 0, 0); + } + #region IDynamicTextureManager Members public void RegisterRender(string handleType, IDynamicTextureRender render) diff --git a/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs b/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs index a08a183..65737fa 100644 --- a/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs @@ -49,21 +49,6 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL private string m_name = "LoadImageURL"; private Scene m_scene; private IDynamicTextureManager m_textureManager; - private IDynamicTextureManager TextureManager - { - get - { - if (m_textureManager == null && m_scene != null) - { - m_textureManager = m_scene.RequestModuleInterface(); - if (m_textureManager != null) - { - m_textureManager.RegisterRender(GetContentType(), this); - } - } - return m_textureManager; - } - } private string m_proxyurl = ""; private string m_proxyexcepts = ""; @@ -146,6 +131,14 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL public void RegionLoaded(Scene scene) { + if (m_textureManager == null && m_scene == scene) + { + m_textureManager = m_scene.RequestModuleInterface(); + if (m_textureManager != null) + { + m_textureManager.RegisterRender(GetContentType(), this); + } + } } public void Close() @@ -191,6 +184,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL private void HttpRequestReturn(IAsyncResult result) { + if (m_textureManager == null) + { + m_log.WarnFormat("[LOADIMAGEURLMODULE]: No texture manager. Can't function."); + return; + } + RequestState state = (RequestState) result.AsyncState; WebRequest request = (WebRequest) state.Request; Stream stream = null; @@ -271,7 +270,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL m_log.DebugFormat("[LOADIMAGEURLMODULE]: Returning {0} bytes of image data for request {1}", imageJ2000.Length, state.RequestID); - TextureManager.ReturnData( + m_textureManager.ReturnData( state.RequestID, new OpenSim.Region.CoreModules.Scripting.DynamicTexture.DynamicTexture( request.RequestUri, null, imageJ2000, newSize, false)); diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs index efa99e9..689e8a7 100644 --- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs @@ -58,21 +58,6 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender private Scene m_scene; private IDynamicTextureManager m_textureManager; - private IDynamicTextureManager TextureManager - { - get - { - if (m_textureManager == null && m_scene != null) - { - m_textureManager = m_scene.RequestModuleInterface(); - if (m_textureManager != null) - { - m_textureManager.RegisterRender(GetContentType(), this); - } - } - return m_textureManager; - } - } private Graphics m_graph; private string m_fontName = "Arial"; @@ -121,8 +106,13 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender public bool AsyncConvertData(UUID id, string bodyData, string extraParams) { + if (m_textureManager == null) + { + m_log.Warn("[VECTORRENDERMODULE]: No texture manager. Can't function"); + return false; + } // XXX: This isn't actually being done asynchronously! - TextureManager.ReturnData(id, ConvertData(bodyData, extraParams)); + m_textureManager.ReturnData(id, ConvertData(bodyData, extraParams)); return true; } @@ -180,6 +170,14 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender public void RegionLoaded(Scene scene) { + if (m_textureManager == null && m_scene == scene) + { + m_textureManager = m_scene.RequestModuleInterface(); + if (m_textureManager != null) + { + m_textureManager.RegisterRender(GetContentType(), this); + } + } } public void RemoveRegion(Scene scene) diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs index f9c1ac2..db0a7fc 100644 --- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs @@ -385,6 +385,11 @@ namespace OpenSim.Tests.Common foreach (IRegionModuleBase module in newModules) { + if (module is ISharedRegionModule) ((ISharedRegionModule)module).PostInitialise(); + } + + foreach (IRegionModuleBase module in newModules) + { foreach (Scene scene in scenes) { module.AddRegion(scene); @@ -392,11 +397,6 @@ namespace OpenSim.Tests.Common } } - foreach (IRegionModuleBase module in newModules) - { - if (module is ISharedRegionModule) ((ISharedRegionModule)module).PostInitialise(); - } - // RegionLoaded is fired after all modules have been appropriately added to all scenes foreach (IRegionModuleBase module in newModules) foreach (Scene scene in scenes) -- cgit v1.1