DropTarget: Fix critical if `reject()` drop before `::enter`
Fixes #5922 (closed)
The docs of Gtk.DropTarget::accept
say this:
If the decision whether the drop will be accepted or rejected depends on the data, [
::accept
] should returnTRUE
, [:preload
] should be set and the value should be inspected via the::notify:value
signal, callinggtk_drop_target_reject()
if required.
But this pattern causes a CRITICAL, given these steps:
- Create a
DragSource
andDropTarget
- Keep the default
::accept
handler and set:preload
toTRUE
- Connect to
notify::value
and therein callDropTarget.reject()
- CRITICAL at
DropTarget.enter()
→Drop.get_actions()
on NULL instance
We should let the documented case work without a CRITICAL or worse, null
deref. And per @otte on the bug we should bail earlier, before ::enter
& setting GTK_STATE_FLAG_DROP_ACTIVE
if reject()ed, unlike at present.
This patch fixes it, and does so unconditional on whether we preload, in
case notify::*drop
may call reject()
, though they probably shouldn’t
Edited by Daniel Boles