From 8b33c43dba5b8b443265d018d8410640f46033b2 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sun, 11 Dec 2022 16:40:47 +0100 Subject: [PATCH] Added support to GridComponent for flushing cached background and selector images on reload when in debug mode. --- es-core/src/components/primary/GridComponent.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/es-core/src/components/primary/GridComponent.h b/es-core/src/components/primary/GridComponent.h index f70e1e862..78dd10e92 100644 --- a/es-core/src/components/primary/GridComponent.h +++ b/es-core/src/components/primary/GridComponent.h @@ -35,6 +35,7 @@ public: using Entry = typename IList::Entry; GridComponent(); + ~GridComponent(); void addEntry(Entry& entry, const std::shared_ptr& theme); void updateEntry(Entry& entry, const std::shared_ptr& theme); @@ -148,12 +149,14 @@ private: unsigned int mImageColorEnd; bool mImageColorGradientHorizontal; std::unique_ptr mBackgroundImage; + std::string mBackgroundImagePath; float mBackgroundRelativeScale; unsigned int mBackgroundColor; unsigned int mBackgroundColorEnd; bool mBackgroundColorGradientHorizontal; bool mHasBackgroundColor; std::unique_ptr mSelectorImage; + std::string mSelectorImagePath; float mSelectorRelativeScale; SelectorLayer mSelectorLayer; unsigned int mSelectorColor; @@ -223,6 +226,18 @@ GridComponent::GridComponent() { } +template GridComponent::~GridComponent() +{ + // Manually flush the background and selector images from the texture cache on destruction + // when running in debug mode, otherwise a complete system view reload would be needed to + // get these images updated. This is useful during theme development when using the Ctrl-r + // keyboard combination to reload the theme configuration. + if (Settings::getInstance()->getBool("Debug")) { + TextureResource::manualUnload(mBackgroundImagePath, false); + TextureResource::manualUnload(mSelectorImagePath, false); + } +} + template void GridComponent::addEntry(Entry& entry, const std::shared_ptr& theme) { @@ -867,6 +882,7 @@ void GridComponent::applyTheme(const std::shared_ptr& theme, } } mBackgroundImage->setImage(elem->get("backgroundImage")); + mBackgroundImagePath = path; } else { LOG(LogWarning) << "GridComponent: Invalid theme configuration, property " @@ -891,6 +907,7 @@ void GridComponent::applyTheme(const std::shared_ptr& theme, } } mSelectorImage->setImage(elem->get("selectorImage")); + mSelectorImagePath = path; } else { LOG(LogWarning) << "GridComponent: Invalid theme configuration, property "