From 56999887670e4f41313217d4798c0690cfc94f58 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sun, 14 Aug 2022 14:46:56 +0200 Subject: [PATCH] Added a workaround for legacy theme sets where the md_releasedate and md_lastplayed element types have incorrectly been defined as text instead of datetime. --- es-core/src/ThemeData.cpp | 29 ++++++++++++++++++++++++----- es-core/src/ThemeData.h | 3 ++- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/es-core/src/ThemeData.cpp b/es-core/src/ThemeData.cpp index e6054837d..71288ede3 100644 --- a/es-core/src/ThemeData.cpp +++ b/es-core/src/ThemeData.cpp @@ -1104,14 +1104,29 @@ void ThemeData::parseView(const pugi::xml_node& root, ThemeView& view) off = nameAttr.find_first_of(delim, prevOff); // Add the element type as a prefix to avoid name collisions between different - // component types. + // component types. Also include a workaround for legacy theme sets if the + // md_releasedate and md_lastplayed element types are incorrectly defined as + // text instead of datetime. const std::string elementType {node.name()}; - elemKey = std::string(node.name()) + "_" + elemKey; + bool dateTimeWorkaround {false}; + + if (mLegacyTheme && elementType == "text" && + (elemKey == "md_releasedate" || elemKey == "md_lastplayed")) { + LOG(LogDebug) << "ThemeData::parseView(): Element type for \"" << elemKey + << "\" incorrectly set to \"text\" " + "instead of \"datetime\", applying workaround"; + dateTimeWorkaround = true; + elemKey = "datetime_" + elemKey; + } + else { + elemKey = elementType + "_" + elemKey; + } parseElement( node, elemTypeIt->second, view.elements.insert(std::pair(elemKey, ThemeElement())) - .first->second); + .first->second, + dateTimeWorkaround); if (mLegacyTheme && std::find(view.legacyOrderedKeys.cbegin(), view.legacyOrderedKeys.cend(), @@ -1123,13 +1138,17 @@ void ThemeData::parseView(const pugi::xml_node& root, ThemeView& view) void ThemeData::parseElement(const pugi::xml_node& root, const std::map& typeMap, - ThemeElement& element) + ThemeElement& element, + bool dateTimeWorkaround) { ThemeException error; error << "ThemeData::parseElement(): "; error.setFiles(mPaths); - element.type = root.name(); + if (dateTimeWorkaround) + element.type = "datetime"; + else + element.type = root.name(); element.extra = root.attribute("extra").as_bool(false); if (mLegacyTheme) diff --git a/es-core/src/ThemeData.h b/es-core/src/ThemeData.h index cc264bcd0..7d5795f6a 100644 --- a/es-core/src/ThemeData.h +++ b/es-core/src/ThemeData.h @@ -252,7 +252,8 @@ private: void parseView(const pugi::xml_node& viewNode, ThemeView& view); void parseElement(const pugi::xml_node& elementNode, const std::map& typeMap, - ThemeElement& element); + ThemeElement& element, + bool dateTimeWorkaround = false); static std::vector sSupportedViews; static std::vector sLegacySupportedViews;