commit 1f06b62d1edd48c61d5d5636cd75b9d80ea967e3
Author: Rick Scott <rwscott@users.sourceforge.net>
Date:   Sun Apr 14 13:27:47 2013 -0400

    Go one step farther to prevent mistakes such as invalid values being stored and used.
    
    The original patch, bff155970773, changed the category type from a string
    to an enum to help avoid mistakes in the future. It however meant that a
    couple of string arrays, and some static int's (added later to fix the fix),
     _must_ be kept in sync. This just changes the type of future mistakes.
    This defines the category type in one place only.

diff --git a/mythtv/libs/libmyth/programinfo.cpp b/mythtv/libs/libmyth/programinfo.cpp
index 968a85c..d834bb6 100644
--- a/mythtv/libs/libmyth/programinfo.cpp
+++ b/mythtv/libs/libmyth/programinfo.cpp
@@ -83,27 +83,31 @@ static void set_flag(uint32_t &flags, int flag_to_set, bool is_set)
 
 QString myth_category_type_to_string(ProgramInfo::CategoryType category_type)
 {
-    static int NUM_CAT_TYPES = 5;
-    static const char *cattype[] =
-        { "", "movie", "series", "sports", "tvshow", };
+#define CATEGORY_TYPE_ITEM(name, ...) \
+    case ProgramInfo::kCategory##name: return(QString(#name).toLower()); break;
 
-    if ((category_type > ProgramInfo::kCategoryNone) &&
-        ((int)category_type < NUM_CAT_TYPES))
-        return QString(cattype[category_type]);
-
-    return "";
+    switch (category_type)
+    {
+    CATEGORY_TYPE_LIST
+    default:
+	return(QString(""));
+	break;
+    }
+#undef CATEGORY_TYPE_ITEM
 }
 
 ProgramInfo::CategoryType string_to_myth_category_type(const QString &category_type)
 {
-    static int NUM_CAT_TYPES = 5;
-    static const char *cattype[] =
-        { "", "movie", "series", "sports", "tvshow", };
+#define CATEGORY_TYPE_ITEM(name, ...) \
+    if (category_type == QString(#name).toLower()) \
+	return(ProgramInfo::kCategory##name); \
+    else
 
-    for (uint i = 1; i < NUM_CAT_TYPES; i++)
-        if (category_type == cattype[i])
-            return (ProgramInfo::CategoryType) i;
-    return ProgramInfo::kCategoryNone;
+    CATEGORY_TYPE_LIST
+    {
+	return(ProgramInfo::kCategoryNone);
+    }
+#undef CATEGORY_TYPE_ITEM
 }
 
 /** \fn ProgramInfo::ProgramInfo(void)
diff --git a/mythtv/libs/libmyth/programinfo.h b/mythtv/libs/libmyth/programinfo.h
index 6e8e263..cb1d827 100644
--- a/mythtv/libs/libmyth/programinfo.h
+++ b/mythtv/libs/libmyth/programinfo.h
@@ -69,12 +69,22 @@ class MSqlQuery;
 class ProgramInfoUpdater;
 class PMapDBReplacement;
 
+#define CATEGORY_TYPE_LIST \
+    CATEGORY_TYPE_ITEM(None) \
+    CATEGORY_TYPE_ITEM(Movie) \
+    CATEGORY_TYPE_ITEM(Series) \
+    CATEGORY_TYPE_ITEM(Sports) \
+    CATEGORY_TYPE_ITEM(TVShow)
+
 class MPUBLIC ProgramInfo
 {
     friend int pginfo_init_statics(void);
   public:
-    enum CategoryType { kCategoryNone, kCategoryMovie, kCategorySeries,
-                        kCategorySports, kCategoryTVShow };
+#define CATEGORY_TYPE_ITEM(name, ...) kCategory##name,
+    enum CategoryType {
+	CATEGORY_TYPE_LIST
+    };
+#undef CATEGORY_TYPE_ITEM
                         
     /// Null constructor
     ProgramInfo(void);
