[gjs: 1/2] GLib: override GThread functions
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 1/2] GLib: override GThread functions
- Date: Wed, 31 Aug 2022 04:25:45 +0000 (UTC)
commit f9d3dbe51e6603b6e821839516520fb9349cfcb4
Author: Andy Holmes <andrew g r holmes gmail com>
Date: Sun Aug 28 10:14:22 2022 -0700
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.
modules/core/overrides/GLib.js | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
---
diff --git a/modules/core/overrides/GLib.js b/modules/core/overrides/GLib.js
index cb8f177e7..deda7dd0c 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');
+ };
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]