GdkDrop: Gdk-CRITICAL when dropping several times
When dropping several times, the drop works, but starting with the second time the following critical log happens with each time, before the 'accept' callback is called:
(python:7168): Gdk-CRITICAL **: 13:13:23.500: gdk_drop_set_actions: assertion 'priv->state == GDK_DROP_STATE_NONE' failed
Python test program, equivalent Rust program gives the same problem.
import gi
gi.require_version('Gtk', '4.0')
from gi.repository import Gtk, Gdk, GLib
mime = "text/plain"
def cb_accept(_target, drop):
formats = drop.get_formats()
if formats is not None:
return formats.contain_mime_type(mime)
return False
def cb_drop(_target, drop, x, y):
formats = drop.get_formats()
if formats is not None:
if formats.contain_mime_type(mime):
drop.read_value_async(GLib.String, GLib.PRIORITY_DEFAULT, None, lambda _drop, value: print(value))
drop.finish(Gdk.DragAction.COPY)
return True
return False
def get_drop_handler():
builder = Gdk.ContentFormatsBuilder()
builder.add_mime_type(mime)
formats = builder.to_formats()
handler = Gtk.DropTargetAsync(formats=formats)
handler.connect('accept', cb_accept)
handler.connect('drop', cb_drop)
return handler
def on_activate(app):
window = Gtk.ApplicationWindow(application=app)
window.set_title("Gtk4 Mime Test")
window.set_default_size(500, 400)
textview = Gtk.TextView()
textview.add_controller(get_drop_handler())
window.set_child(textview)
window.present()
# Create a new application
app = Gtk.Application(application_id='com.example.GtkApplication')
app.connect('activate', on_activate)
# Run the application
app.run(None)
Current behavior
Critical log happens.
Expected outcome
No critical log. If the API is used incorrectly, please give a hint in the documentation how to use it correctly.
Version information
Gtk 4.0.3 via Pacman on X11, Arch Linux. Python bindings: Master from https://gitlab.gnome.org/GNOME/pygobject/
Edited by Sebastian Dröge