Skip to content

Commit 84f4899

Browse files
committed
Fix Qt SVG warnings on Linux
Fixed "qt.svg: Invalid path data; path truncated" warnings that appeared 4 times at startup when running DataLab on Ubuntu/Linux. Closes #278 (cherry picked from commit 396e816) # Conflicts: # doc/locale/fr/LC_MESSAGES/release_notes/release_1.00.po
1 parent 40446f0 commit 84f4899

File tree

5 files changed

+130
-3
lines changed

5 files changed

+130
-3
lines changed

datalab/data/icons/create/linear_chirp.svg

Lines changed: 1 addition & 1 deletion
Loading

datalab/data/icons/create/logistic.svg

Lines changed: 1 addition & 1 deletion
Loading

doc/locale/fr/LC_MESSAGES/release_notes/release_1.00.po

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: DataLab \n"
99
"Report-Msgid-Bugs-To: \n"
10-
"POT-Creation-Date: 2025-12-12 19:37+0100\n"
10+
"POT-Creation-Date: 2025-12-13 10:35+0100\n"
1111
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1212
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1313
"Language: fr\n"
@@ -27,6 +27,18 @@ msgstr ""
2727
msgid "🛠️ Bug Fixes since version 1.0.2"
2828
msgstr "🛠️ Correctifs depuis la version 1.0.2"
2929

30+
msgid "**Icons - Qt SVG warnings on Linux:**"
31+
msgstr "**Icônes - Avertissements Qt SVG sous Linux :**"
32+
33+
msgid "Fixed \"qt.svg: Invalid path data; path truncated\" warnings appearing 4 times at startup on Linux/Ubuntu"
34+
msgstr "Correction des avertissements « qt.svg: Invalid path data; path truncated » apparaissant 4 fois au démarrage sous Linux/Ubuntu"
35+
36+
msgid "Cleaned SVG icon files to remove Inkscape/Sodipodi metadata and fixed path syntax in two icon files that used implicit cubic Bézier command continuation (not supported by Qt's SVG renderer on Linux)"
37+
msgstr "Nettoyage des fichiers d'icônes SVG pour supprimer les métadonnées Inkscape/Sodipodi et correction de la syntaxe des chemins dans deux fichiers d'icônes qui utilisaient une continuation implicite de commande de courbe de Bézier cubique (non prise en charge par le moteur de rendu SVG de Qt sous Linux)"
38+
39+
msgid "This closes [Issue #278](https://github.com/datalab-platform/datalab/issues/278) - Fix \"qt.svg: Invalid path data; path truncated\" warnings on Linux"
40+
msgstr "Ceci clôture [Issue #278](https://github.com/datalab-platform/datalab/issues/278) - Correction des avertissements « qt.svg: Invalid path data; path truncated » sous Linux"
41+
3042
msgid "**ROI extraction - KeyError when extracting ROIs:**"
3143
msgstr "**Extraction de ROI - KeyError lors de l'extraction des ROI :**"
3244

doc/release_notes/release_1.00.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
### 🛠️ Bug Fixes since version 1.0.2 ###
66

7+
**Icons - Qt SVG warnings on Linux:**
8+
9+
* Fixed "qt.svg: Invalid path data; path truncated" warnings appearing 4 times at startup on Linux/Ubuntu
10+
* Cleaned SVG icon files to remove Inkscape/Sodipodi metadata and fixed path syntax in two icon files that used implicit cubic Bézier command continuation (not supported by Qt's SVG renderer on Linux)
11+
* This closes [Issue #278](https://github.com/datalab-platform/datalab/issues/278) - Fix "qt.svg: Invalid path data; path truncated" warnings on Linux
12+
713
**ROI extraction - KeyError when extracting ROIs:**
814

915
* Fixed `KeyError` when extracting ROIs from images with ROIs generated by blob detection or other analysis functions

scripts/debug_svg_warnings.py

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
#!/usr/bin/env python3
2+
"""Script to identify which SVG files trigger Qt warnings.
3+
4+
This script scans all SVG files in the icon directories and loads them
5+
one by one, reporting which files cause Qt SVG warnings.
6+
"""
7+
8+
from __future__ import annotations
9+
10+
import sys
11+
from pathlib import Path
12+
13+
from guidata.qthelpers import qt_app_context
14+
from qtpy import QtCore as QC
15+
from qtpy import QtGui as QG
16+
17+
from datalab.config import DATAPATH
18+
19+
# Add project root to path
20+
project_root = Path(__file__).parent.parent
21+
sys.path.insert(0, str(project_root))
22+
23+
# Track which file is currently being loaded
24+
current_file: Path | None = None
25+
problematic_files: set[Path] = set()
26+
27+
28+
def message_handler(
29+
msg_type: QC.QtMsgType, context: QC.QMessageLogContext, message: str
30+
) -> None:
31+
"""Custom Qt message handler to catch SVG warnings."""
32+
if "svg" in message.lower() or "path" in message.lower():
33+
if current_file is not None and current_file not in problematic_files:
34+
problematic_files.add(current_file)
35+
print(f" ⚠️ {current_file.name}: {message}")
36+
37+
38+
def scan_svg_directory(svg_dir: Path) -> None:
39+
"""Scan all SVG files in a directory and test loading them."""
40+
if not svg_dir.exists():
41+
print(f"Directory not found: {svg_dir}")
42+
return
43+
44+
svg_files = sorted(svg_dir.rglob("*.svg"))
45+
print(f"\nScanning {len(svg_files)} SVG files in {svg_dir}...")
46+
print("-" * 60)
47+
48+
global current_file
49+
for svg_file in svg_files:
50+
current_file = svg_file
51+
relative_path = svg_file.relative_to(svg_dir)
52+
# Load the icon - this triggers Qt SVG parsing
53+
icon = QG.QIcon(str(svg_file))
54+
# Force the icon to actually render by getting a pixmap
55+
pixmap = icon.pixmap(32, 32)
56+
if pixmap.isNull():
57+
print(f" ❌ Failed to load: {relative_path}")
58+
59+
current_file = None
60+
61+
62+
def main() -> None:
63+
"""Main function to scan SVG icons."""
64+
with qt_app_context():
65+
# Install custom message handler
66+
QC.qInstallMessageHandler(message_handler)
67+
68+
print("=" * 60)
69+
print("SVG Icon Scanner - Detecting problematic SVG files")
70+
print("=" * 60)
71+
72+
# Scan DataLab icons
73+
scan_svg_directory(Path(DATAPATH))
74+
75+
# Try to find and scan guidata icons
76+
try:
77+
import guidata
78+
79+
guidata_path = Path(guidata.__file__).parent
80+
guidata_icons = guidata_path / "data" / "icons"
81+
scan_svg_directory(guidata_icons)
82+
except ImportError:
83+
print("\nguidata not found, skipping its icons")
84+
85+
# Try to find and scan plotpy icons
86+
try:
87+
import plotpy
88+
89+
plotpy_path = Path(plotpy.__file__).parent
90+
plotpy_icons = plotpy_path / "data" / "icons"
91+
scan_svg_directory(plotpy_icons)
92+
except ImportError:
93+
print("\nplotpy not found, skipping its icons")
94+
95+
# Summary
96+
print("\n" + "=" * 60)
97+
print("SUMMARY")
98+
print("=" * 60)
99+
100+
if problematic_files:
101+
print(f"\n❌ Found {len(problematic_files)} problematic SVG file(s):\n")
102+
for file_path in sorted(problematic_files):
103+
print(f" • {file_path}\n")
104+
else:
105+
print("\n✅ No problematic SVG files found!")
106+
107+
108+
if __name__ == "__main__":
109+
main()

0 commit comments

Comments
 (0)