Fix issues with the DynamicTextureModule and corresponding unit tests.

integration
Diva Canto 2012-11-11 19:39:21 -08:00
parent 113a9704f2
commit db418bff2b
4 changed files with 44 additions and 37 deletions

View File

@ -83,6 +83,16 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
/// </remarks> /// </remarks>
private Cache m_reuseableDynamicTextures; private Cache m_reuseableDynamicTextures;
/// <summary>
/// This constructor is only here because of the Unit Tests...
/// Don't use it.
/// </summary>
public DynamicTextureModule()
{
m_reuseableDynamicTextures = new Cache(CacheMedium.Memory, CacheStrategy.Conservative);
m_reuseableDynamicTextures.DefaultTTL = new TimeSpan(24, 0, 0);
}
#region IDynamicTextureManager Members #region IDynamicTextureManager Members
public void RegisterRender(string handleType, IDynamicTextureRender render) public void RegisterRender(string handleType, IDynamicTextureRender render)

View File

@ -49,21 +49,6 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL
private string m_name = "LoadImageURL"; private string m_name = "LoadImageURL";
private Scene m_scene; private Scene m_scene;
private IDynamicTextureManager m_textureManager; private IDynamicTextureManager m_textureManager;
private IDynamicTextureManager TextureManager
{
get
{
if (m_textureManager == null && m_scene != null)
{
m_textureManager = m_scene.RequestModuleInterface<IDynamicTextureManager>();
if (m_textureManager != null)
{
m_textureManager.RegisterRender(GetContentType(), this);
}
}
return m_textureManager;
}
}
private string m_proxyurl = ""; private string m_proxyurl = "";
private string m_proxyexcepts = ""; private string m_proxyexcepts = "";
@ -146,6 +131,14 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL
public void RegionLoaded(Scene scene) public void RegionLoaded(Scene scene)
{ {
if (m_textureManager == null && m_scene == scene)
{
m_textureManager = m_scene.RequestModuleInterface<IDynamicTextureManager>();
if (m_textureManager != null)
{
m_textureManager.RegisterRender(GetContentType(), this);
}
}
} }
public void Close() public void Close()
@ -191,6 +184,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL
private void HttpRequestReturn(IAsyncResult result) 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; RequestState state = (RequestState) result.AsyncState;
WebRequest request = (WebRequest) state.Request; WebRequest request = (WebRequest) state.Request;
Stream stream = null; 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}", m_log.DebugFormat("[LOADIMAGEURLMODULE]: Returning {0} bytes of image data for request {1}",
imageJ2000.Length, state.RequestID); imageJ2000.Length, state.RequestID);
TextureManager.ReturnData( m_textureManager.ReturnData(
state.RequestID, state.RequestID,
new OpenSim.Region.CoreModules.Scripting.DynamicTexture.DynamicTexture( new OpenSim.Region.CoreModules.Scripting.DynamicTexture.DynamicTexture(
request.RequestUri, null, imageJ2000, newSize, false)); request.RequestUri, null, imageJ2000, newSize, false));

View File

@ -58,21 +58,6 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
private Scene m_scene; private Scene m_scene;
private IDynamicTextureManager m_textureManager; private IDynamicTextureManager m_textureManager;
private IDynamicTextureManager TextureManager
{
get
{
if (m_textureManager == null && m_scene != null)
{
m_textureManager = m_scene.RequestModuleInterface<IDynamicTextureManager>();
if (m_textureManager != null)
{
m_textureManager.RegisterRender(GetContentType(), this);
}
}
return m_textureManager;
}
}
private Graphics m_graph; private Graphics m_graph;
private string m_fontName = "Arial"; private string m_fontName = "Arial";
@ -121,8 +106,13 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
public bool AsyncConvertData(UUID id, string bodyData, string extraParams) 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! // XXX: This isn't actually being done asynchronously!
TextureManager.ReturnData(id, ConvertData(bodyData, extraParams)); m_textureManager.ReturnData(id, ConvertData(bodyData, extraParams));
return true; return true;
} }
@ -180,6 +170,14 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
public void RegionLoaded(Scene scene) public void RegionLoaded(Scene scene)
{ {
if (m_textureManager == null && m_scene == scene)
{
m_textureManager = m_scene.RequestModuleInterface<IDynamicTextureManager>();
if (m_textureManager != null)
{
m_textureManager.RegisterRender(GetContentType(), this);
}
}
} }
public void RemoveRegion(Scene scene) public void RemoveRegion(Scene scene)

View File

@ -383,6 +383,11 @@ namespace OpenSim.Tests.Common
} }
} }
foreach (IRegionModuleBase module in newModules)
{
if (module is ISharedRegionModule) ((ISharedRegionModule)module).PostInitialise();
}
foreach (IRegionModuleBase module in newModules) foreach (IRegionModuleBase module in newModules)
{ {
foreach (Scene scene in scenes) foreach (Scene scene in scenes)
@ -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 // RegionLoaded is fired after all modules have been appropriately added to all scenes
foreach (IRegionModuleBase module in newModules) foreach (IRegionModuleBase module in newModules)
foreach (Scene scene in scenes) foreach (Scene scene in scenes)