From 8b1e297fc6567ead2c400199348d89e17b552899 Mon Sep 17 00:00:00 2001 From: Hein-Pieter van Braam-Stewart Date: Sat, 20 Apr 2019 01:57:29 +0200 Subject: Don't crash on printing nested types When adding an Array or Dictionary to itself operator String() got in an infinite loop. This commit adds a stack to operator String() (Through the use of a new 'stringify method'). This stack keeps track of all unique Arrays and Dictionaries it has seen. When a duplicate is found only a static string is printed '[...]' or '{...}'. This mirror Python's behavior in a similar case. --- core/variant.h | 1 + 1 file changed, 1 insertion(+) (limited to 'core/variant.h') diff --git a/core/variant.h b/core/variant.h index 9215d15bf0..5151262f27 100644 --- a/core/variant.h +++ b/core/variant.h @@ -401,6 +401,7 @@ public: bool hash_compare(const Variant &p_variant) const; bool booleanize() const; + String stringify(List &stack) const; void static_assign(const Variant &p_variant); static void get_constructor_list(Variant::Type p_type, List *p_list); -- cgit v1.2.3