diff options
author | Andy Holmes <andrew.g.r.holmes@gmail.com> | 2022-08-28 10:14:22 -0700 |
---|---|---|
committer | Andy Holmes <andrew.g.r.holmes@gmail.com> | 2022-08-28 10:14:22 -0700 |
commit | f9d3dbe51e6603b6e821839516520fb9349cfcb4 (patch) | |
tree | e3a83093d43739769a0bd57d8703739d902e530b | |
parent | e86716d8129156f56d1b0418de8bc9bf0adb5c43 (diff) | |
download | gjs-f9d3dbe51e6603b6e821839516520fb9349cfcb4.tar.gz |
GLib: override GThread functions
These are almost entirely unusable from GJS and the few functions that
don't crash outright shouldn't be called by user code.
-rw-r--r-- | modules/core/overrides/GLib.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/modules/core/overrides/GLib.js b/modules/core/overrides/GLib.js index cb8f177e..deda7dd0 100644 --- a/modules/core/overrides/GLib.js +++ b/modules/core/overrides/GLib.js @@ -505,4 +505,27 @@ function _init() { const invalidRegex = new RegExp(`[^${escapedValidArray.join('')}]`, 'g'); return string.replace(invalidRegex, substitutor); }; + + // Prevent user code from calling GThread functions which always crash + this.Thread.new = function () { + throw _notIntrospectableError('GLib.Thread.new()', + 'GIO asynchronous methods or Promise()'); + }; + + this.Thread.try_new = function () { + throw _notIntrospectableError('GLib.Thread.try_new()', + 'GIO asynchronous methods or Promise()'); + }; + + this.Thread.exit = function () { + throw new Error('\'GLib.Thread.exit()\' may not be called in GJS'); + }; + + this.Thread.prototype.ref = function () { + throw new Error('\'GLib.Thread.ref()\' may not be called in GJS'); + }; + + this.Thread.prototype.unref = function () { + throw new Error('\'GLib.Thread.unref()\' may not be called in GJS'); + }; } |