cleanup: Remove old compatibility code

Since gjs moved to mozjs60, return values of int8_t arrays can
no longer be treated as strings. We originally made the conversion
conditional to keep working with the (then) stable gjs release.

That was two years ago and we require a more recent gjs nowadays,
so there's no good reason for keeping the old code path.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1407
This commit is contained in:
Florian Müllner 2020-08-13 23:35:27 +02:00 committed by Georges Basile Stavracas Neto
parent 923d926345
commit 112b139a9e
5 changed files with 10 additions and 15 deletions

View File

@ -2,6 +2,7 @@
/* exported Component */ /* exported Component */
const { Clutter, Gio, GLib, GObject, NM, Pango, Shell, St } = imports.gi; const { Clutter, Gio, GLib, GObject, NM, Pango, Shell, St } = imports.gi;
const ByteArray = imports.byteArray;
const Signals = imports.signals; const Signals = imports.signals;
const Dialog = imports.ui.dialog; const Dialog = imports.ui.dialog;
@ -522,13 +523,7 @@ var VPNRequestHandler = class {
let contentOverride; let contentOverride;
try { try {
data = this._dataStdout.peek_buffer(); data = ByteArray.toGBytes(this._dataStdout.peek_buffer());
if (data instanceof Uint8Array)
data = imports.byteArray.toGBytes(data);
else
data = data.toGBytes();
keyfile.load_from_bytes(data, GLib.KeyFileFlags.NONE); keyfile.load_from_bytes(data, GLib.KeyFileFlags.NONE);
if (keyfile.get_integer(VPN_UI_GROUP, 'Version') != 2) if (keyfile.get_integer(VPN_UI_GROUP, 'Version') != 2)

View File

@ -2,6 +2,7 @@
/* exported init connect disconnect */ /* exported init connect disconnect */
const { GLib, Gio, GObject, Shell, St } = imports.gi; const { GLib, Gio, GObject, Shell, St } = imports.gi;
const ByteArray = imports.byteArray;
const Signals = imports.signals; const Signals = imports.signals;
const ExtensionDownloader = imports.ui.extensionDownloader; const ExtensionDownloader = imports.ui.extensionDownloader;
@ -282,8 +283,7 @@ var ExtensionManager = class {
let metadataContents, success_; let metadataContents, success_;
try { try {
[success_, metadataContents] = metadataFile.load_contents(null); [success_, metadataContents] = metadataFile.load_contents(null);
if (metadataContents instanceof Uint8Array) metadataContents = ByteArray.toString(metadataContents);
metadataContents = imports.byteArray.toString(metadataContents);
} catch (e) { } catch (e) {
throw new Error('Failed to load metadata.json: %s'.format(e.toString())); throw new Error('Failed to load metadata.json: %s'.format(e.toString()));
} }

View File

@ -2,6 +2,7 @@
/* exported KeyboardManager */ /* exported KeyboardManager */
const { Clutter, Gio, GLib, GObject, Meta, St } = imports.gi; const { Clutter, Gio, GLib, GObject, Meta, St } = imports.gi;
const ByteArray = imports.byteArray;
const Signals = imports.signals; const Signals = imports.signals;
const InputSourceManager = imports.ui.status.keyboard; const InputSourceManager = imports.ui.status.keyboard;
@ -532,8 +533,7 @@ var KeyboardModel = class {
_loadModel(groupName) { _loadModel(groupName) {
let file = Gio.File.new_for_uri('resource:///org/gnome/shell/osk-layouts/%s.json'.format(groupName)); let file = Gio.File.new_for_uri('resource:///org/gnome/shell/osk-layouts/%s.json'.format(groupName));
let [success_, contents] = file.load_contents(null); let [success_, contents] = file.load_contents(null);
if (contents instanceof Uint8Array) contents = ByteArray.toString(contents);
contents = imports.byteArray.toString(contents);
return JSON.parse(contents); return JSON.parse(contents);
} }

View File

@ -3,6 +3,7 @@
const { Atk, Clutter, GDesktopEnums, Gio, const { Atk, Clutter, GDesktopEnums, Gio,
GLib, GObject, Gtk, Meta, Pango, Rsvg, St } = imports.gi; GLib, GObject, Gtk, Meta, Pango, Rsvg, St } = imports.gi;
const ByteArray = imports.byteArray;
const Signals = imports.signals; const Signals = imports.signals;
const Main = imports.ui.main; const Main = imports.ui.main;
@ -297,8 +298,7 @@ var PadDiagram = GObject.registerClass({
_init(params) { _init(params) {
let file = Gio.File.new_for_uri('resource:///org/gnome/shell/theme/pad-osd.css'); let file = Gio.File.new_for_uri('resource:///org/gnome/shell/theme/pad-osd.css');
let [success_, css] = file.load_contents(null); let [success_, css] = file.load_contents(null);
if (css instanceof Uint8Array) css = ByteArray.toString(css);
css = imports.byteArray.toString(css);
this._curEdited = null; this._curEdited = null;
this._prevEdited = null; this._prevEdited = null;
this._css = css; this._css = css;

View File

@ -1,6 +1,7 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
/* exported SessionMode, listModes */ /* exported SessionMode, listModes */
const ByteArray = imports.byteArray;
const GLib = imports.gi.GLib; const GLib = imports.gi.GLib;
const Signals = imports.signals; const Signals = imports.signals;
@ -105,8 +106,7 @@ function _loadMode(file, info) {
let fileContent, success_, newMode; let fileContent, success_, newMode;
try { try {
[success_, fileContent] = file.load_contents(null); [success_, fileContent] = file.load_contents(null);
if (fileContent instanceof Uint8Array) fileContent = ByteArray.toString(fileContent);
fileContent = imports.byteArray.toString(fileContent);
newMode = JSON.parse(fileContent); newMode = JSON.parse(fileContent);
} catch (e) { } catch (e) {
return; return;