Don't start dragging invalid items in generic wxDataViewCtrl

It's not useful to allow dragging from the control area where there are
no items and it resulted in assert failures due to using an invalid row
in wxDataViewDropSource::GiveFeedback(), so simply don't do it at all.

Note that native GTK wxDataViewCtrl implementation doesn't do this
neither, so it also makes the behaviour more consistent.

Closes https://github.com/wxWidgets/wxWidgets/pull/1828
This commit is contained in:
Konstantin S. Matveyev
2020-04-29 17:02:44 +03:00
committed by Vadim Zeitlin
parent fd2aea0352
commit bcddfd6efb

View File

@@ -4703,6 +4703,9 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event )
m_owner->CalcUnscrolledPosition( m_dragStart.x, m_dragStart.y,
&m_dragStart.x, &m_dragStart.y );
unsigned int drag_item_row = GetLineAt( m_dragStart.y );
if (drag_item_row >= GetRowCount() || m_dragStart.x > GetEndOfLastCol())
return;
wxDataViewItem itemDragged = GetItemByRow( drag_item_row );
// Notify cell about drag