Bug 196634 - ksvgtopng crashes with some svg files
Summary: ksvgtopng crashes with some svg files
Status: RESOLVED FIXED
Alias: None
Product: kdelibs
Classification: Unmaintained
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-15 17:09 UTC by Martin Jansa
Modified: 2009-06-18 10:58 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
ksvgtopng.initQApplication.patch (550 bytes, patch)
2009-06-15 18:03 UTC, Martin Jansa
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Jansa 2009-06-15 17:09:49 UTC
Version:           kdebase-runtime-4.2.4, qt-4.5.1 (using KDE 4.2.4)
Compiler:          gcc version 4.4.0 (Gentoo 4.4.0 p1.0) 
OS:                Linux
Installed from:    Compiled From Sources

martin@jama ~/ksvgtopng-test $ wget https://navit.svn.sourceforge.net/svnroot/navit/trunk/navit/navit/xpm/bank.svg
martin@jama ~/ksvgtopng-test $ ksvgtopng 20 20 bank.svg bank.png
Segmentation fault

with debug enabled it says:
ASSERT failure in QFontDatabase: "A QApplication object needs to be constructed before FontConfig is used.", file text/qfontdatabase_x11.cpp, line 994

Confirmed on 2 computers (both amd64), one with qt-4.5.1, kde-4.2.4 and second with recent qt-copy snapshot and kde-4.2.91.

It looks like qt bug, I'll try to create smaller test-case without ksvgtopng to report it to qt-devs.
Comment 1 Martin Jansa 2009-06-15 18:03:10 UTC
Created attachment 34549 [details]
ksvgtopng.initQApplication.patch

Initialize Qt application, otherwise for some svg files it can segfault with:

ASSERT failure in QFontDatabase: "A QApplication object needs to be constructed before FontConfig is used."
Comment 2 Christoph Feck 2009-06-16 20:32:13 UTC
SVN commit 982740 by cfeck:

Use QApplication (for SVG files with text)

Patch by Martin Jansa, thanks!
BUG: 196634


 M  +6 -0      ksvgtopng.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=982740
Comment 3 Martin Jansa 2009-06-18 10:46:04 UTC
(In reply to comment #2)
> SVN commit 982740 by cfeck:
> 
> Use QApplication (for SVG files with text)
> 
> Patch by Martin Jansa, thanks!
> BUG: 196634
> 
> 
>  M  +6 -0      ksvgtopng.cpp  
> 
> 
> WebSVN link: http://websvn.kde.org/?view=rev&revision=982740

It has unwanted side effect, that it needs X11 connection, so batch converting of png files, like when compiling referenced navit suffers from this change, when run from commandline without X11 :(.

SRCDIR=. ./navit_svg2png "/usr/bin/ksvgtopng" "gui_inactive.png"
ksvgtopng: cannot connect to X server

Strange that this bug appears only on certain SVG files with text.
https://navit.svn.sourceforge.net/svnroot/navit/trunk/navit/navit/xpm/cursor_still.svg
worked ok, even before my change and has text with some font too. What's even stranger, is that when I replaced whole <text> element in bank.svg with <text> element from cursor_still.svg than resulting svg segfaults again :(.

Maybe there is still some hidden bug in qt code after all...
Comment 4 Martin Jansa 2009-06-18 10:58:24 UTC
(In reply to comment #3)
https://navit.svn.sourceforge.net/svnroot/navit/trunk/navit/navit/xpm/cursor_still.svg
> worked ok, even before my change and has text with some font too. What's even
> stranger, is that when I replaced whole <text> element in bank.svg with <text>
> element from cursor_still.svg than resulting svg segfaults again :(.

Ah my fault to notice..

cursor_still.svg has <text> but in layer with style="display:none", so it wasn't rendered at all.

It would be nice to have qt function like
bool QSvgRenderer::animated () const
for check if svg has <text> elements and only then init QApplication.