Browse Source

Release old element decorator data after generating new data

This gives the decorator the opportunity to reuse any cached resources. Particularly helpful for the SVG cache.
Michael Ragazzon 7 months ago
parent
commit
6ebe3df0ac
1 changed files with 5 additions and 2 deletions
  1. 5 2
      Source/Core/ElementEffects.cpp

+ 5 - 2
Source/Core/ElementEffects.cpp

@@ -162,12 +162,15 @@ void ElementEffects::ReloadEffectsData()
 		{
 		{
 			for (DecoratorEntry& decorator : *list)
 			for (DecoratorEntry& decorator : *list)
 			{
 			{
-				if (decorator.decorator_data)
-					decorator.decorator->ReleaseElementData(decorator.decorator_data);
+				const DecoratorDataHandle old_data = decorator.decorator_data;
 
 
 				decorator.decorator_data = decorator.decorator->GenerateElementData(element, decorator.paint_area);
 				decorator.decorator_data = decorator.decorator->GenerateElementData(element, decorator.paint_area);
 				if (!decorator.decorator_data)
 				if (!decorator.decorator_data)
 					decorator_data_failed = true;
 					decorator_data_failed = true;
+
+				// Release old element data after generating new data, so that the decorator can reuse any cache.
+				if (old_data)
+					decorator.decorator->ReleaseElementData(old_data);
 			}
 			}
 		}
 		}