summaryrefslogtreecommitdiffstats
path: root/core/variant.h
diff options
context:
space:
mode:
authorHein-Pieter van Braam-Stewart <hp@tmm.cx>2019-04-20 01:57:29 +0200
committerHein-Pieter van Braam-Stewart <hp@tmm.cx>2019-04-20 02:01:55 +0200
commit8b1e297fc6567ead2c400199348d89e17b552899 (patch)
tree7cc302337a56767015ae4b716cc2ac8fae57c557 /core/variant.h
parent8e652a1400ee20b99cf4829e8b4883fe3f254d59 (diff)
downloadredot-engine-8b1e297fc6567ead2c400199348d89e17b552899.tar.gz
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.
Diffstat (limited to 'core/variant.h')
-rw-r--r--core/variant.h1
1 files changed, 1 insertions, 0 deletions
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<const void *> &stack) const;
void static_assign(const Variant &p_variant);
static void get_constructor_list(Variant::Type p_type, List<MethodInfo> *p_list);