Skip to content

Commit e52d6ac

Browse files
author
Milkii Brewster
committed
tests: add SVG text regression test; total 26 tests
test_icon_svgs_have_no_text_elements: parse canvas.svg and pb_clementine.svg with ElementTree and assert no <text>/<flowRoot> elements are present. Guards against re-introduction of the Qt6 SVG renderer crash where font-size:0.6px;line-height:0% → QFont::setPixelSize(0) → SIGSEGV in QFontEngineFT::loadGlyph.
1 parent 39ce4b3 commit e52d6ac

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

tests/test_frontend.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,44 @@ def test_settings_load_save_reset_cover_default_project():
101101
)
102102

103103

104+
# ----------------------------------------------------------------------------
105+
# SVG icon regression: no <text>/<flowRoot> that crash Qt6 SVG renderer
106+
# ----------------------------------------------------------------------------
107+
108+
_REPO = os.path.join(FRONTEND, '..', '..')
109+
# Only the SVGs confirmed to crash Qt6's SVG renderer:
110+
# canvas.svg — font-size:~0.6px;line-height:0% → QFont::setPixelSize(0)
111+
# pb_clementine.svg — font-family:Duepuntozero (never installed) → invalid glyph
112+
# carla.svg / carla-control.svg use font-family:Sans at 16px + line-height:125% and are safe.
113+
_SCALABLE_SVGs = [
114+
'resources/scalable/canvas.svg',
115+
'resources/scalable/pb_clementine.svg',
116+
]
117+
118+
def test_icon_svgs_have_no_text_elements():
119+
"""Qt6's QSvgText::draw_helper segfaults when font-size resolves to 0 or
120+
the referenced font-family is not installed. Verify the affected icon SVGs
121+
contain no <text> or <flowRoot> elements (bugfix/svg-text-qt6-crash)."""
122+
import xml.etree.ElementTree as ET
123+
CRASH_TAGS = {
124+
'{http://www.w3.org/2000/svg}text',
125+
'{http://www.w3.org/2000/svg}flowRoot',
126+
}
127+
offenders = []
128+
for relpath in _SCALABLE_SVGs:
129+
path = os.path.join(_REPO, relpath)
130+
if not os.path.exists(path):
131+
continue
132+
tree = ET.parse(path)
133+
for node in tree.iter():
134+
if node.tag in CRASH_TAGS:
135+
offenders.append(f'{relpath}: {node.tag}')
136+
assert not offenders, (
137+
'SVG text elements found — will crash Qt6 SVG renderer:\n' +
138+
'\n'.join(offenders)
139+
)
140+
141+
104142
# ----------------------------------------------------------------------------
105143
# Feature-branch regression tests (source scanning, no display needed)
106144
# ----------------------------------------------------------------------------

0 commit comments

Comments
 (0)