[gjs: 2/6] Gio: avoid redefining the original function name multiple times
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 2/6] Gio: avoid redefining the original function name multiple times
- Date: Thu, 21 Jul 2022 17:54:41 +0000 (UTC)
commit 95456fc196faec140aace6eca1d00c60ed3cbe09
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Fri Jul 8 04:17:07 2022 +0200
Gio: avoid redefining the original function name multiple times
modules/core/overrides/Gio.js | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/modules/core/overrides/Gio.js b/modules/core/overrides/Gio.js
index 8db01c22b..b1377d7e5 100644
--- a/modules/core/overrides/Gio.js
+++ b/modules/core/overrides/Gio.js
@@ -425,15 +425,16 @@ function _promisify(proto, asyncFunc,
if (proto[finishFunc] === undefined)
throw new Error(`${proto} has no method named ${finishFunc}`);
- if (proto[`_original_${asyncFunc}`] !== undefined)
+ const originalFuncName = `_original_${asyncFunc}`;
+ if (proto[originalFuncName] !== undefined)
return;
- proto[`_original_${asyncFunc}`] = proto[asyncFunc];
+ proto[originalFuncName] = proto[asyncFunc];
proto[asyncFunc] = function (...args) {
if (!args.every(arg => typeof arg !== 'function'))
- return this[`_original_${asyncFunc}`](...args);
+ return this[originalFuncName](...args);
return new Promise((resolve, reject) => {
const callStack = new Error().stack.split('\n').filter(line =>
!line.match(/promisify/)).join('\n');
- this[`_original_${asyncFunc}`](...args, function (source, res) {
+ this[originalFuncName](...args, function (source, res) {
try {
const result = source !== null && source[finishFunc] !== undefined
? source[finishFunc](res)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]