Ticket #2132: mythtv-0.19-themecachesize.patch

File mythtv-0.19-themecachesize.patch, 2.0 KB (added by Sonni Nørløv <sonni.norlov@…>, 13 years ago)
  • libs/libmyth/mythcontext.cpp

     
    12891289
    12901290    QFileInfoListIterator it(*list);
    12911291    QFileInfo *fi;
     1292    QMap<QDateTime, QString> dirtimes;
    12921293
    12931294    while ((fi = it.current()) != 0)
    12941295    {
     
    12991300        {
    13001301            if (fi->absFilePath() == themecachedir)
    13011302                continue;
    1302             RemoveCacheDir(fi->absFilePath());
     1303            dirtimes[fi->lastModified()] = fi->absFilePath();
    13031304        }
    13041305    }
     1306
     1307    const size_t max_cached = GetNumSetting("ThemeCacheSize", 1);
     1308    while (dirtimes.size() >= max_cached)
     1309    {
     1310        RemoveCacheDir(dirtimes.begin().data());
     1311        dirtimes.erase(dirtimes.begin());
     1312    }
     1313
     1314    for(QMap<QDateTime, QString>::const_iterator i = dirtimes.begin(); i != dirtimes.end(); ++i)
     1315    {
     1316        VERBOSE(VB_IMPORTANT, "Keeping cache dir: " << (*i).data());
     1317    }
    13051318}
    13061319
    13071320void MythContext::RemoveCacheDir(const QString &dirname)
  • programs/mythfrontend/globalsettings.cpp

     
    728728    return gs;
    729729}
    730730
     731static HostSpinBox *ThemeCacheSize()
     732{
     733    HostSpinBox *gs = new HostSpinBox("ThemeCacheSize", 1, 1000, 1, true);
     734    gs->setLabel(QObject::tr("Theme cache size"));
     735    gs->setValue(1);
     736    gs->setHelpText(QObject::tr("Maximum number of prescaled themes to cache."));
     737    return gs;
     738}
     739
    731740static HostComboBox *MenuTheme()
    732741{
    733742    HostComboBox *gc = new HostComboBox("MenuTheme");
     
    32503259    theme->addChild(ThemeFontSizeType());
    32513260    theme->addChild(RandomTheme());
    32523261    theme->addChild(MenuTheme());
     3262    theme->addChild(ThemeCacheSize());
    32533263    addChild(theme);
    32543264
    32553265    VerticalConfigurationGroup* screen = new VerticalConfigurationGroup(false);