Commit ec99fa95 authored by H1Gdev's avatar H1Gdev Committed by mrbean-bremen
Browse files

Fix: Crash viewer when entering text.

- Catch exceptions in event handler.
parent 838008c1
...@@ -21,6 +21,8 @@ namespace SVGViewer ...@@ -21,6 +21,8 @@ namespace SVGViewer
} }
private void open_Click(object sender, EventArgs e) private void open_Click(object sender, EventArgs e)
{
try
{ {
if (openSvgFile.ShowDialog() == DialogResult.OK) if (openSvgFile.ShowDialog() == DialogResult.OK)
{ {
...@@ -28,15 +30,25 @@ namespace SVGViewer ...@@ -28,15 +30,25 @@ namespace SVGViewer
RenderSvg(svgDoc); RenderSvg(svgDoc);
} }
} }
catch
{
}
}
private void textBox1_TextChanged(object sender, EventArgs e) private void textBox1_TextChanged(object sender, EventArgs e)
{ {
using(var s = new MemoryStream(Encoding.UTF8.GetBytes(textBox1.Text))) try
{
using (var s = new MemoryStream(Encoding.UTF8.GetBytes(textBox1.Text)))
{ {
SvgDocument svgDoc = SvgDocument.Open<SvgDocument>(s, null); SvgDocument svgDoc = SvgDocument.Open<SvgDocument>(s, null);
RenderSvg(svgDoc); RenderSvg(svgDoc);
} }
} }
catch
{
}
}
private void RenderSvg(SvgDocument svgDoc) private void RenderSvg(SvgDocument svgDoc)
{ {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment