Fix some PNG loading issues on Windows

Fix #2085
This commit is contained in:
Julien Duponchelle
2017-06-08 14:59:47 +02:00
parent 802b80b764
commit 13a8bd4500
2 changed files with 11 additions and 1 deletions

View File

@@ -53,7 +53,7 @@ class QImageSvgRenderer(QtSvg.QSvgRenderer):
# We load the SVG with ElementTree before
# because Qt when failing loading send noise to logs
# and their is no way to prevent that
if not path_or_data.startswith(":"):
if not path_or_data.startswith(":") and os.path.exists(path_or_data):
ET.parse(path_or_data)
res = super().load(path_or_data)
# If we can't render a SVG we load and base64 the image to create a SVG

View File

@@ -29,3 +29,13 @@ def test_render_svg():
def test_render_png():
renderer = QImageSvgRenderer('resources/images/gns3_icon_256x256.png')
assert renderer.isValid()
def test_render_text_svg():
renderer = QImageSvgRenderer('<svg></svg>')
assert renderer.isValid()
def test_render_text_broken_svg():
renderer = QImageSvgRenderer('<svg></svg')
assert renderer.isValid() is False