Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ImportedProjects
SVG
Commits
ec99fa95
Commit
ec99fa95
authored
Dec 20, 2018
by
H1Gdev
Committed by
mrbean-bremen
Dec 20, 2018
Browse files
Fix: Crash viewer when entering text.
- Catch exceptions in event handler.
parent
838008c1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Samples/SVGViewer/SvgViewer.cs
View file @
ec99fa95
...
...
@@ -22,28 +22,40 @@ namespace SVGViewer
private
void
open_Click
(
object
sender
,
EventArgs
e
)
{
if
(
openSvgFile
.
ShowDialog
()
==
DialogResult
.
OK
)
try
{
if
(
openSvgFile
.
ShowDialog
()
==
DialogResult
.
OK
)
{
SvgDocument
svgDoc
=
SvgDocument
.
Open
(
openSvgFile
.
FileName
);
RenderSvg
(
svgDoc
);
}
}
catch
{
SvgDocument
svgDoc
=
SvgDocument
.
Open
(
openSvgFile
.
FileName
);
RenderSvg
(
svgDoc
);
}
}
private
void
textBox1_TextChanged
(
object
sender
,
EventArgs
e
)
{
using
(
var
s
=
new
MemoryStream
(
Encoding
.
UTF8
.
GetBytes
(
textBox1
.
Text
)))
{
SvgDocument
svgDoc
=
SvgDocument
.
Open
<
SvgDocument
>(
s
,
null
);
RenderSvg
(
svgDoc
);
}
try
{
using
(
var
s
=
new
MemoryStream
(
Encoding
.
UTF8
.
GetBytes
(
textBox1
.
Text
)))
{
SvgDocument
svgDoc
=
SvgDocument
.
Open
<
SvgDocument
>(
s
,
null
);
RenderSvg
(
svgDoc
);
}
}
catch
{
}
}
private
void
RenderSvg
(
SvgDocument
svgDoc
)
{
//var render = new DebugRenderer();
//svgDoc.Draw(render);
svgImage
.
Image
=
svgDoc
.
Draw
();
string
outputDir
;
if
(
svgDoc
.
BaseUri
==
null
)
outputDir
=
System
.
IO
.
Path
.
GetDirectoryName
(
Application
.
ExecutablePath
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment