Fixing a bug when open the nameseditor directly after start that images are not created

This commit is contained in:
BlubbFish 2021-08-29 00:48:41 +02:00
parent 47fe56304f
commit 6702c6392c

View File

@ -8,6 +8,8 @@ using BlubbFish.Utils;
namespace Fraunhofer.Fit.IoT.LoraMap.Model.Svg { namespace Fraunhofer.Fit.IoT.LoraMap.Model.Svg {
public class SvgModel : OwnSingeton<SvgModel> { public class SvgModel : OwnSingeton<SvgModel> {
private readonly Dictionary<String, SVGFile> svgtable = new Dictionary<String, SVGFile>(); private readonly Dictionary<String, SVGFile> svgtable = new Dictionary<String, SVGFile>();
private readonly Object lockSVG = new Object();
public Boolean ParseRequest(HttpListenerContext cont) { public Boolean ParseRequest(HttpListenerContext cont) {
Byte[] svg = this.GetSvg(cont.Request.Url.PathAndQuery); Byte[] svg = this.GetSvg(cont.Request.Url.PathAndQuery);
if(svg.Length > 0) { if(svg.Length > 0) {
@ -26,14 +28,16 @@ namespace Fraunhofer.Fit.IoT.LoraMap.Model.Svg {
if(this.svgtable.ContainsKey(pathAndQuery)) { if(this.svgtable.ContainsKey(pathAndQuery)) {
return Encoding.UTF8.GetBytes(this.svgtable[pathAndQuery].ToString()); return Encoding.UTF8.GetBytes(this.svgtable[pathAndQuery].ToString());
} else { } else {
if(pathAndQuery.StartsWith("/api/svg/marker.svg") && pathAndQuery.Contains("?")) { lock(this.lockSVG) {
String query = pathAndQuery[(pathAndQuery.IndexOf('?') + 1)..]; if(pathAndQuery.StartsWith("/api/svg/marker.svg") && pathAndQuery.Contains("?")) {
this.svgtable.Add(pathAndQuery, new SVGMarker(query)); String query = pathAndQuery[(pathAndQuery.IndexOf('?') + 1)..];
return Encoding.UTF8.GetBytes(this.svgtable[pathAndQuery].ToString()); this.svgtable.Add(pathAndQuery, new SVGMarker(query));
} else if(pathAndQuery.StartsWith("/api/svg/person.svg") && pathAndQuery.Contains("?")) { return Encoding.UTF8.GetBytes(this.svgtable[pathAndQuery].ToString());
String query = pathAndQuery[(pathAndQuery.IndexOf('?') + 1)..]; } else if(pathAndQuery.StartsWith("/api/svg/person.svg") && pathAndQuery.Contains("?")) {
this.svgtable.Add(pathAndQuery, new SVGPerson(query)); String query = pathAndQuery[(pathAndQuery.IndexOf('?') + 1)..];
return Encoding.UTF8.GetBytes(this.svgtable[pathAndQuery].ToString()); this.svgtable.Add(pathAndQuery, new SVGPerson(query));
return Encoding.UTF8.GetBytes(this.svgtable[pathAndQuery].ToString());
}
} }
} }
return new Byte[0]; return new Byte[0];