Details
-
Suggestion
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.2.2
-
None
Description
SVG graphics can be hellish to debug due to limited information logged by Qt. Given that SVG is being used a lot in KDE land, it doesn't really help to see tens of identical messages in console like this:
qt.svg: <input>:303:258: Could not add child element to parent element because the types are incorrect. qt.svg: <input>:303:463: Could not add child element to parent element because the types are incorrect. qt.svg: <input>:303:659: Could not add child element to parent element because the types are incorrect. qt.svg: <input>:303:913: Could not add child element to parent element because the types are incorrect. qt.svg: <input>:303:1049: Could not add child element to parent element because the types are incorrect. qt.svg: <input>:303:1251: Could not add child element to parent element because the types are incorrect. qt.svg: <input>:303:1453: Could not add child element to parent element because the types are incorrect. qt.svg: <input>:303:1631: Could not add child element to parent element because the types are incorrect. qt.svg: <input>:303:1739: Could not add child element to parent element because the types are incorrect. qt.svg: <input>:303:1980: Could not add child element to parent element because the types are incorrect. qt.svg: <input>:303:2223: Could not add child element to parent element because the types are incorrect.
which types? where's that input? who's the parent? guess, we'll never know…
The code responsible for this is inherently magic and non-flexible:
static QByteArray prefixMessage(const QByteArray &msg, const QXmlStreamReader *r) { QByteArray result; if (r) { if (const QFile *file = qobject_cast<const QFile *>(r->device())) result.append(QFile::encodeName(QDir::toNativeSeparators(file->fileName()))); else result.append(QByteArrayLiteral("<input>"));
Instead of specifying the source (file name) manually, it attempts to to guess that using hard-coded dynamic cast at runtime which is also designed to work only for "real" files on disk. This is about one and a half layers of indirection beyond what's acceptable for encapsulation.