diff options
author | Philip Chimento <philip.chimento@gmail.com> | 2022-08-31 04:25:44 +0000 |
---|---|---|
committer | Philip Chimento <philip.chimento@gmail.com> | 2022-08-31 04:25:44 +0000 |
commit | e78966e18b8a68292bfea7132cc4a1d0d4dcc231 (patch) | |
tree | 63da53f9ec5ce81ba8744b38df6948bb3833837c | |
parent | 5719874a7551aa5fcf7a96e35b4fe9828440d2fc (diff) | |
parent | f9d3dbe51e6603b6e821839516520fb9349cfcb4 (diff) | |
download | gjs-e78966e18b8a68292bfea7132cc4a1d0d4dcc231.tar.gz |
Merge branch 'wip/andyholmes/gthread-override' into 'master'
GLib: override GThread functions
See merge request GNOME/gjs!795
-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'); + }; } |