Skip to content

Make PlatformTheme share data when possible

Arjen Hiemstra requested to merge work/ahiemstra/platformtheme into master

In an average application, there will be a lot of PlatformTheme instances, since they will be attached to almost every object. However, PlatformThemePrivate is currently almost 800 bytes large. Along with some other things, this means we are using a lot of memory for each PlatformTheme instance.

This MR changes things by having the data shared between instances of PlatformTheme when they inherit. This greatly reduces the number of actual data objects that are needed, since the majority of PlatformTheme instances will inherit. On a slightly contrived test with 10000 items (and 10000 PlatformTheme instances) this reduces memory usage from 110MB to 70MB, though for that result additional changes are needed in qqc2-desktop-style's plugin.

To ensure things are working the way they should, this also includes an autotest to verify PlatformTheme's behaviour.

Draft because:

  • test_inherit in the autotest currently fails.
  • test_override in the autotest currently fails.
  • BasicTheme needs to be updated and improved.
  • Needs lots more testing.
Edited by Arjen Hiemstra

Merge request reports