[gjs] overrides/GLib: fix maybe GVariants unpacking



commit 8bd9dfc233c000b89f3ebf851e5245ad7f0ed84c
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Thu Jul 17 21:50:51 2014 +0200

    overrides/GLib: fix maybe GVariants unpacking
    
    With regression tests

 installed-tests/js/testEverythingEncapsulated.js |    6 ++++++
 modules/overrides/GLib.js                        |    2 +-
 2 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/installed-tests/js/testEverythingEncapsulated.js 
b/installed-tests/js/testEverythingEncapsulated.js
index acd956b..8b375f6 100644
--- a/installed-tests/js/testEverythingEncapsulated.js
+++ b/installed-tests/js/testEverythingEncapsulated.js
@@ -186,6 +186,12 @@ function testVariantConstructor() {
     JSUnit.assertEquals('variant', unpacked[3].deep_unpack());
     JSUnit.assertTrue(unpacked[4] instanceof Array);
     JSUnit.assertEquals(2, unpacked[4].length);
+
+    let maybe_variant = new GLib.Variant('ms', null);
+    JSUnit.assertEquals(null, maybe_variant.deep_unpack());
+
+    maybe_variant = new GLib.Variant('ms', 'string');
+    JSUnit.assertEquals('string', maybe_variant.deep_unpack());
 }
 
 JSUnit.gjstestRun(this, JSUnit.setUp, JSUnit.tearDown);
diff --git a/modules/overrides/GLib.js b/modules/overrides/GLib.js
index c0c445d..f4161a2 100644
--- a/modules/overrides/GLib.js
+++ b/modules/overrides/GLib.js
@@ -200,7 +200,7 @@ function _unpack_variant(variant, deep) {
        return variant.get_variant();
     case 'm':
        let val = variant.get_maybe();
-       if (deep)
+       if (deep && val)
            return _unpack_variant(val, deep);
        else
            return val;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]