[gjs/gnome-40: 2/30] fundamental: Use g_value_type_compatible to check if we can do type conversion
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/gnome-40: 2/30] fundamental: Use g_value_type_compatible to check if we can do type conversion
- Date: Wed, 5 May 2021 20:41:25 +0000 (UTC)
commit 74ba0988b4644bef930829decc5128cdd57ccb20
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Thu Apr 8 17:07:55 2021 +0200
fundamental: Use g_value_type_compatible to check if we can do type conversion
While it's quite similar to what we did already, it adds a further layer
of protection, by ensuring that the GValue can hold both types.
Since that's what we eventually care.
(cherry-picked from commit b49a465b)
gi/fundamental.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/gi/fundamental.cpp b/gi/fundamental.cpp
index 0e83028c..e443dc7a 100644
--- a/gi/fundamental.cpp
+++ b/gi/fundamental.cpp
@@ -464,7 +464,7 @@ bool FundamentalBase::to_gvalue(JSContext* cx, JS::HandleObject obj,
auto* instance = priv->to_instance();
if (!instance->set_value(gvalue)) {
- if (g_type_is_a(instance->gtype(), G_VALUE_TYPE(gvalue))) {
+ if (g_value_type_compatible(instance->gtype(), G_VALUE_TYPE(gvalue))) {
g_value_set_instance(gvalue, instance->m_ptr);
return true;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]