[gjs: 3/14] 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: 3/14] fundamental: Use g_value_type_compatible to check if we can do type conversion
 
- Date: Sat, 17 Apr 2021 04:36:47 +0000 (UTC)
 
commit b49a465b0bff7d5990430c8a5ac6ff5bdc48d324
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.
 gi/fundamental.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/gi/fundamental.cpp b/gi/fundamental.cpp
index 824e72e1..d3221193 100644
--- a/gi/fundamental.cpp
+++ b/gi/fundamental.cpp
@@ -467,7 +467,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]