From 23d64740c144c6126e9c91059bc59b48af679314 Mon Sep 17 00:00:00 2001 From: CapitaineJSparrow <6690149+CapitaineJSparrow@users.noreply.github.com> Date: Tue, 4 Oct 2022 08:49:40 +0200 Subject: [PATCH] fix undefined value not converted to gobject --- src/value.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/value.cc b/src/value.cc index 03a9dd47..997cc4e7 100644 --- a/src/value.cc +++ b/src/value.cc @@ -1368,8 +1368,15 @@ void FreeGIArgumentArray(GITypeInfo *type_info, GIArgument *arg, GITransfer tran */ bool CanConvertV8ToGValue(GValue *gvalue, Local value) { + auto maybeDetailString = Nan::ToDetailString(value); + Nan::Utf8String utf8String( + !maybeDetailString.IsEmpty() ? + maybeDetailString.ToLocalChecked() : + UTF8("[invalid value]") + ); + // void/null - if (G_VALUE_TYPE(gvalue) == G_TYPE_INVALID) + if (G_VALUE_TYPE(gvalue) == G_TYPE_INVALID || strcmp(*utf8String,"undefined") == 0) return value->IsNullOrUndefined(); if (G_VALUE_HOLDS_BOOLEAN (gvalue)) { @@ -1426,8 +1433,7 @@ bool V8ToGValue(GValue *gvalue, Local value, bool mustCopy) { maybeDetailString.ToLocalChecked() : UTF8("[invalid value]") ); - Throw::TypeError("Cannot convert value \"%s\" to type %s", - *utf8String, G_VALUE_TYPE_NAME (gvalue)); + Throw::TypeError("Cannot convert value \"%s\" to type %s",*utf8String, G_VALUE_TYPE_NAME (gvalue)); return false; }