From 4a5e0fe95f31de14d0d8447ca688d61df2ed02a5 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Thu, 27 Jul 2017 12:49:09 +0700 Subject: [PATCH] Convert nil strings to empty GodotString --- godot/core/strings.nim | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/godot/core/strings.nim b/godot/core/strings.nim index 0a800ac..d8ebc30 100644 --- a/godot/core/strings.nim +++ b/godot/core/strings.nim @@ -55,8 +55,14 @@ proc `$`*(self: GodotString): string = proc toGodotString*(s: string): GodotString {.inline.} = ## Converts the Nim string into ``GodotString`` - initGodotString(result, unsafeAddr s[0], cint(s.len + 1)) + if s.isNil: + initGodotString(result) + else: + initGodotString(result, unsafeAddr s[0], cint(s.len + 1)) proc toGodotString*(s: cstring): GodotString {.inline.} = ## Converts the cstring into ``GodotString`` - initGodotString(result, s, cint(s.len + 1)) + if s.isNil: + initGodotString(result) + else: + initGodotString(result, s, cint(s.len + 1))