Ableton / aqt-stylesheets

Apply CSS style sheets to QML applications
Other
214 stars 39 forks source link

Make the fontIdCache owned by the StyleEngineHost #21

Closed nsh-ableton closed 9 years ago

nsh-ableton commented 9 years ago

When using qmltestrunner to run QML unit tests, the QML engine is destroyed and recreated. This means that the QFontDatabase used by the StyleEngine is also destroyed and recreated. Unfortunately, the QFontDatabase does not ask the window manager to remove fonts when it is destroyed. Therefore, if a StyleEngine has previously loaded a font, and then tries to load the same font in the next test run, QFontDatabase will call the OS-specific font loading code, which (at least on Mac OS) will generate an error.

The solution here is to make the fontIdCache that the StyleEngine uses a member of the StyleEngineHost, which is a singleton that is preserved across destruction and recreation of the QML engine. The StyleEngine thus "knows" which fonts have previously been loaded, and will not try to load them again.