[gjs: 1/2] GLib: Fix regression in GVariant packing



commit ce07c4af2458313c4f7245b2ddcbeca3affaea04
Author: Philip Chimento <philip endlessm com>
Date:   Wed Sep 12 18:21:52 2018 -0700

    GLib: Fix regression in GVariant packing
    
    This was a use of the old ByteArray API that hadn't been updated.
    
    Closes: #202

 installed-tests/js/testGLib.js | 8 ++++++++
 modules/overrides/GLib.js      | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/installed-tests/js/testGLib.js b/installed-tests/js/testGLib.js
index 46516718..f7e80274 100644
--- a/installed-tests/js/testGLib.js
+++ b/installed-tests/js/testGLib.js
@@ -1,3 +1,4 @@
+const ByteArray = imports.byteArray;
 const GLib = imports.gi.GLib;
 
 describe('GVariant constructor', function () {
@@ -40,4 +41,11 @@ describe('GVariant constructor', function () {
         maybe_variant = new GLib.Variant('ms', 'string');
         expect(maybe_variant.deep_unpack()).toEqual('string');
     });
+
+    it('constructs a byte array variant', function () {
+        const byteArray = Uint8Array.from('pizza', c => c.charCodeAt(0));
+        const byteArrayVariant = new GLib.Variant('ay', byteArray);
+        expect(ByteArray.toString(byteArrayVariant.deep_unpack()))
+            .toEqual('pizza');
+    });
 });
diff --git a/modules/overrides/GLib.js b/modules/overrides/GLib.js
index 9f90d22c..3f247ea8 100644
--- a/modules/overrides/GLib.js
+++ b/modules/overrides/GLib.js
@@ -68,7 +68,7 @@ function _read_single_type(signature, forceSimple) {
 
 function _makeBytes(byteArray) {
     if (byteArray instanceof Uint8Array || byteArray instanceof ByteArray.ByteArray)
-        return byteArray.toGBytes();
+        return ByteArray.toGBytes(byteArray);
     else
         return new GLib.Bytes(byteArray);
 }


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