Copy dropped data to wxDataViewEvent

Existing code relies on GetDataBuffer() returning a valid pointer, so we
need to ensure that this is the case, even if this means copying the
data into an internal buffer.
This commit is contained in:
Vadim Zeitlin
2021-12-10 20:30:24 +01:00
parent 7797ffc730
commit 33018ea7a9
2 changed files with 12 additions and 1 deletions

View File

@@ -1812,7 +1812,17 @@ void wxDataViewEvent::InitData(wxDataObjectComposite* obj, wxDataFormat format)
SetDataFormat(format);
SetDataObject(obj->GetObject(format));
SetDataSize(obj->GetDataSize(format));
const size_t size = obj->GetDataSize(format);
SetDataSize(size);
if ( size )
{
obj->GetDataHere(format, m_dataBuf.GetWriteBuf(size));
m_dataBuf.UngetWriteBuf(size);
SetDataBuffer(m_dataBuf.GetData());
}
}
#endif // wxUSE_DRAG_AND_DROP