Skip to content

Fix Object implementing interface toString

toString() on an object implementing an interface currently leads to an error.

Fixes this by trying to use the ObjectBase implementation for to_string().

A workaroundish version of it is also possible in JS only:

diff --git a/modules/overrides/GObject.js b/modules/overrides/GObject.js
index c6ea6ad9..44e2adc7 100644
--- a/modules/overrides/GObject.js
+++ b/modules/overrides/GObject.js
@@ -126,9 +126,9 @@ function _propertiesAsArray(klass) {
     return propertiesArray;
 }
 
-function _copyAllDescriptors(target, source) {
+function _copyAllDescriptors(target, source, filter) {
     Object.getOwnPropertyNames(source)
-    .filter(key => !['prototype', 'constructor'].includes(key))
+    .filter(key => !(['prototype', 'constructor'].concat(filter)).includes(key))
     .concat(Object.getOwnPropertySymbols(source))
     .forEach(key => {
         let descriptor = Object.getOwnPropertyDescriptor(source, key);
@@ -354,7 +355,7 @@ function _init() {
 
         _copyAllDescriptors(newClass, klass);
         gobjectInterfaces.forEach(iface =>
-            _copyAllDescriptors(newClass.prototype, iface.prototype));
+            _copyAllDescriptors(newClass.prototype, iface.prototype, 'toString'));
         _copyAllDescriptors(newClass.prototype, klass.prototype);
 
         Object.getOwnPropertyNames(newClass.prototype)
Edited by Marco Trevisan

Merge request reports