Index: libs/libmyth/mythcontext.cpp
===================================================================
--- libs/libmyth/mythcontext.cpp	(revision 10688)
+++ libs/libmyth/mythcontext.cpp	(working copy)
@@ -1289,6 +1289,7 @@
 
     QFileInfoListIterator it(*list);
     QFileInfo *fi;
+    QMap<QDateTime, QString> dirtimes;
 
     while ((fi = it.current()) != 0)
     {
@@ -1299,9 +1300,21 @@
         {
             if (fi->absFilePath() == themecachedir)
                 continue;
-            RemoveCacheDir(fi->absFilePath());
+            dirtimes[fi->lastModified()] = fi->absFilePath();
         }
     }
+
+    const size_t max_cached = GetNumSetting("ThemeCacheSize", 1);
+    while (dirtimes.size() >= max_cached)
+    {
+        RemoveCacheDir(dirtimes.begin().data());
+        dirtimes.erase(dirtimes.begin());
+    }
+
+    for(QMap<QDateTime, QString>::const_iterator i = dirtimes.begin(); i != dirtimes.end(); ++i)
+    {
+        VERBOSE(VB_IMPORTANT, "Keeping cache dir: " << (*i).data());
+    }
 }
 
 void MythContext::RemoveCacheDir(const QString &dirname)
Index: programs/mythfrontend/globalsettings.cpp
===================================================================
--- programs/mythfrontend/globalsettings.cpp	(revision 10688)
+++ programs/mythfrontend/globalsettings.cpp	(working copy)
@@ -728,6 +728,15 @@
     return gs;
 }
 
+static HostSpinBox *ThemeCacheSize()
+{
+    HostSpinBox *gs = new HostSpinBox("ThemeCacheSize", 1, 1000, 1, true);
+    gs->setLabel(QObject::tr("Theme cache size"));
+    gs->setValue(1);
+    gs->setHelpText(QObject::tr("Maximum number of prescaled themes to cache."));
+    return gs;
+}
+
 static HostComboBox *MenuTheme()
 {
     HostComboBox *gc = new HostComboBox("MenuTheme");
@@ -3250,6 +3259,7 @@
     theme->addChild(ThemeFontSizeType());
     theme->addChild(RandomTheme());
     theme->addChild(MenuTheme());
+    theme->addChild(ThemeCacheSize());
     addChild(theme);
 
     VerticalConfigurationGroup* screen = new VerticalConfigurationGroup(false);
