LibGUI: Return early if drag_data_type is null (#3919)

If the user tries to drag an item with a null drag data type from an
AbstractView, return from the mouse event early.
This commit is contained in:
Joseph 2020-11-02 21:26:38 +00:00 committed by GitHub
parent 5ed7ca3627
commit 9efcb5d290
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: sideshowbarker 2024-07-19 17:32:40 +09:00

View file

@ -265,6 +265,10 @@ void AbstractView::mousemove_event(MouseEvent& event)
auto hovered_index = index_at_event_position(event.position()); auto hovered_index = index_at_event_position(event.position());
set_hovered_index(hovered_index); set_hovered_index(hovered_index);
auto data_type = m_model->drag_data_type();
if (data_type.is_null())
return ScrollableWidget::mousemove_event(event);
if (!m_might_drag) if (!m_might_drag)
return ScrollableWidget::mousemove_event(event); return ScrollableWidget::mousemove_event(event);
@ -280,7 +284,6 @@ void AbstractView::mousemove_event(MouseEvent& event)
if (distance_travelled_squared <= drag_distance_threshold) if (distance_travelled_squared <= drag_distance_threshold)
return ScrollableWidget::mousemove_event(event); return ScrollableWidget::mousemove_event(event);
auto data_type = m_model->drag_data_type();
ASSERT(!data_type.is_null()); ASSERT(!data_type.is_null());
dbg() << "Initiate drag!"; dbg() << "Initiate drag!";