Browse Source

Added ASSERT check for recursion error and minor code cleanup

David Wimsey 11 years ago
parent
commit
564c4c4618
1 changed files with 6 additions and 2 deletions
  1. 6 2
      Source/Core/ElementStyle.cpp

+ 6 - 2
Source/Core/ElementStyle.cpp

@@ -408,9 +408,13 @@ float ElementStyle::ResolveProperty(const String& name, float base_value)
 			{
 				Rocket::Core::ElementDocument* owner_document = element->GetOwnerDocument();
 				if (owner_document == NULL)
-					return 0;
+					return 0.0f;
+
+				/// @TODO In release mode, using REM on a body tag will result in an infinite recursion loop
+				/// and eventually a stack overflow crash, this needs to be resolved.
+				ROCKET_ASSERTMSG(owner_document != element, "REM unit is not allowed on document or body root.");
 
-				base_value = element->GetOwnerDocument()->ResolveProperty(FONT_SIZE, 0);
+				base_value = owner_document->ResolveProperty(FONT_SIZE, 0);
 			}
 			else
 			{