`const char **` out parameter gets incorrect transfer-full annotation by default
System information
What is your operating system and version? (e.g. "Linux, Fedora 29" or "macOS 10.13")
Linux Ubuntu/Arch/Manjaro
What is your version of GJS? (e.g. "1.54.1-fc29.1" or "commit gjs@4ab70efb")
1.74
If the bug is related to GNOME Shell, what is your version of GNOME Shell? (e.g. "3.30.1-2ubuntu1" or "commit b405ed64")
I don't think related to shell, however using 42 currently.
Bug information
Steps to reproduce
Create a Gtk.DropTargetAsync
Add to widget
Elect to read a particular mime type in the drop
Drop the mime type
GJS crashes with the following error-
munmap_chunk(): invalid pointer zsh: IOT instruction (core dumped) ./dropproblem.js
Even better, if the problem can be observed by executing a standalone JS file, paste that here instead of the steps. `Use code blocks (```js) to format it.
In the example program, run the Program. Drag a file from Nautilus and drop on the window. GJS crashes. Expected output should be a text URI list of files dragged onto the window.
#!/usr/bin/env gjs
imports.gi.versions.Gtk = "4.0";
const { Gio, Gtk, Gdk, GLib } = imports.gi;
class ImageViewerWindow {
constructor(app) {
this._app = app;
this._window = null;
this.textDecoder = new TextDecoder();
}
_buildUI() {
this._window = new Gtk.ApplicationWindow({
application: this._app,
defaultHeight: 600,
defaultWidth: 800
});
this._buttonClick = Gtk.GestureClick.new();
this._buttonClick.set_button(0);
this._buttonClick.set_propagation_phase(Gtk.PropagationPhase.BUBBLE);
this._window.add_controller(this._buttonClick);
this._buttonClick.connect('pressed', (actor, n_press, x, y) => {
let button = actor.get_current_button();
let state = this._buttonClick.get_current_event().get_modifier_state();
let anotherstate = this._buttonClick.get_current_event_state();
log(state);
log(anotherstate);
});
this.gridDropController = new Gtk.DropTargetAsync();
this.gridDropController.set_actions(Gdk.DragAction.MOVE | Gdk.DragAction.COPY | Gdk.DragAction.ASK);
let desktopAcceptFormats = Gdk.ContentFormats.new([ 'x-special/gnome-icon-list', 'text/uri-list', 'text/plain;charset=utf-8']);
this.gridDropController.set_formats(desktopAcceptFormats);
let acceptFormat = null;
let dropData = null;
this.gridDropController.connect('accept', (actor, drop) => {
if (drop.get_formats().match(desktopAcceptFormats))
return true;
});
this.gridDropController.connect('drag-enter', () => {
log('drag enter')
return Gdk.DragAction.MOVE;
});
this.gridDropController.connect('drag-motion', (actor, drop, x, y) => {
log('drag-move')
return Gdk.DragAction.MOVE;
});
this.gridDropController.connect('drag-leave', () => {
log('drag-leave')
});
this.gridDropController.connect('drop', (actor, drop, x, y) => {
log(drop.get_formats().to_string())
drop.read_async(['text/uri-list'], GLib.PRIORITY_DEFAULT, null, (dropactor, result) => {
try {
let success = dropactor.read_finish(result);
let bytes = success[0].read_bytes(8192, null);
text = this.textDecoder.decode(bytes.get_data());
log(text);
} catch (e) {
print(`Exception while reading drop: ${e.message}\n${e.stack}`);
}
});
});
this._window.add_controller(this.gridDropController);
}
getWidget() {
this._buildUI();
return this._window;
}
}
const application = new Gtk.Application({
application_id: 'org.gnome.Sandbox.MenuExample',
flags: Gio.ApplicationFlags.FLAGS_NONE
});
application.connect('activate', app => {
let activeWindow = app.activeWindow;
if (!activeWindow) {
let imageViewerWindow = new ImageViewerWindow(app);
activeWindow = imageViewerWindow.getWidget();
}
activeWindow.present();
});
application.run(null);
Current behaviour
What happened that made it evident there was a problem? Copy and paste the exact text of any error messages. Use code blocks (```) to format them.
Using DropTargetAsync in my program. Can only use methods read_value_async() and read_value_finisj() on the drop to read GObjects, unable to read mime types with methods read_async(), read_finish().
Expected behaviour
What did you expect to see instead?
Should be able to read the text