[Kde-games-devel] Faster KGameThemeSelector startup
Matt Williams
matt at milliams.com
Fri Jun 1 13:53:53 CEST 2007
> Hi, guys!
>
> While playing with KGameThemeSelector dialog, I noticed that even with
> only two themes in it, it starts rather slow.
>
> It turned out, that the faulty piece of code is KGameTheme::load(),
> because it checks whether svg file is valid by loading it with
> KSvgRenderer. Svg loading is performed only for this check, there are
> no further actions with loaded svg.
>
> I know it is a good check, that guarantees further success to games
> that use KGameTheme, but isn't it too heavy? :)
>
> While starting, KGameThemeSelector is calling KGameTheme::load on every
> theme it finds, so just imagine how long it'll take to display this
> dialog if a game has say 10 themes.
>
> What I propose is to replace KSvgRenderer->load(...) with simple and
> fast QFile::open(...) to test if file exists and can be opened
> (i.e. file permissions are permittable ;-) )
> And the check for SVG validity can be done in application itself,
>t which uses KSvgRenderer::load & friends anyway.
>
> Mauricio, what do you think as KGameTheme's author?
> Simple patch attached.
> Any objections against me committing it?
I agree that the full check on the SVG isn't necessary, there _shouldn't_
ever be any problem with loading the file anyway as long as it exists. The
patch looks perfect. Maybe a note should be added to the API docs saying
that though the theme could be loaded, no check on the SVG file contents
was made so the user should check it themselves? Commit away as far as I'm
concerned. Maraucio, what do you think?
Matt Williams
http://milliams.com
More information about the kde-games-devel
mailing list