Gdk.ContentProvider.get_value() no longer accepts a GValue
System information
What is your operating system and version? GNOME Flatpak Platform 42
What is your version of GJS? 1.72.0
Bug information
Steps to reproduce
import Gdk from 'gi://Gdk?version=4.0';
import GObject from 'gi://GObject';
const value = new GObject.Value();
value.init(GObject.TYPE_STRING);
value.set_string('OK');
const provider = Gdk.ContentProvider.new_for_value(value);
const [ok, newValue] = provider.get_value();
console.log(newValue.get_string());
Current behaviour
Trying to retrieve the value of a Gtk.ContentProvider
throws several criticals:
$ flatpak run --command=gjs --filesystem=home org.gnome.Platform//42 -m test.js
(gjs:2): Gdk-CRITICAL **: 16:55:42.490: gdk_content_provider_get_value: assertion 'G_IS_VALUE (value)' failed
(gjs:2): GLib-GObject-CRITICAL **: 16:55:42.490: g_value_type_transformable: assertion 'src_type' failed
(gjs:2): GLib-GObject-CRITICAL **: 16:55:42.490: g_value_type_transformable: assertion 'src_type' failed
(gjs:2): Gjs-CRITICAL **: 16:55:42.490: JS ERROR: Error: Don't know how to convert GType (null) to JavaScript object
@file:///test.js:12:33
(gjs:2): Gjs-CRITICAL **: 16:55:42.490: Module file:///test.js threw an exception
Expected behaviour
We should be able to tell the type of the GValue that should be returned, for example with provider.get_value(GObject.TYPE_STRING
).
Interestingly, with GJS 1.70.2, the function signature is different, and we can pass it an already initialized GValue:
import Gdk from 'gi://Gdk?version=4.0';
import GObject from 'gi://GObject';
const value = new GObject.Value();
value.init(GObject.TYPE_STRING);
value.set_string('OK');
const provider = Gdk.ContentProvider.new_for_value(value);
const newValue = new GObject.Value();
newValue.init(GObject.TYPE_STRING)
const _ok = provider.get_value(newValue);
console.log(newValue.get_string());
And that works as expected:
$ flatpak run --command=gjs --filesystem=home org.gnome.Platform//41 -m test.js
Gjs-Console-Message: 17:00:24.319: OK