Skip to content

DataViewCtrl drag-and-drop non-functional on GTK: GetDataBuffer() returns opaque void*; GetDataObject() returns None in drop handler #2867

@maxfritzler

Description

@maxfritzler

Environment

  • wxPython 4.2.5 gtk3 (Phoenix) / wxWidgets 3.2.9
  • Linux / GTK3

Summary

wx.dataview.DataViewCtrl drag-and-drop is non-functional on GTK from Python because
the SWIG bindings do not expose drop payload data in a usable form.

Bug 1: GetDataBuffer() returns opaque C pointer

In EVT_DATAVIEW_ITEM_DROP, event.GetDataBuffer() returns a raw SWIG void*
pointer (<Swig Object of type 'void *' at 0x...>) rather than a Python bytes
object. It is impossible to read the dragged data.

def on_drop(self, event):
    buf = event.GetDataBuffer()
    # buf is a void* — cannot call .decode(), bytes(), memoryview(), etc.
    # No way to reconstruct what was dragged

Bug 2: GetDataObject() returns None in drop handler

Users also report event.GetDataObject() returns None inside the drop handler,
providing no alternative route to the data.

Bug 3 (possibly fixed in Phoenix): double-free on SetDataObject()

The original wxWidgets issue #16881 (closed "outdated" in 2017 with a redirect to
Phoenix) documented a crash when calling event.SetDataObject(obj) in
EVT_DATAVIEW_ITEM_BEGIN_DRAG on GTK because Python and C++ both attempt to free
the object. The workaround was obj.this.disown(). It is unclear whether Phoenix's
ownership model has resolved this.

Related

Impact

DataViewCtrl with PyDataViewModel would be a clean MVC alternative to wx.TreeCtrl
for tree UIs on GTK, but the broken DnD bindings make it unusable for any application
requiring drag-and-drop reordering on Linux.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions