From 10c4349e47d9b17e75f82472cd4e7a97a85bb112 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thi=C3=A9baud=20Weksteen?= Date: Fri, 18 Apr 2025 20:41:06 +1000 Subject: [PATCH] Ignore invalid drop in timeline Fixes #972 In the timeline widget, if a piece is dropped beyond the last step, it will disappear from the model. Ignore these invalid drag and drops. --- common/lc_timelinewidget.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/common/lc_timelinewidget.cpp b/common/lc_timelinewidget.cpp index 5085302e..3de0d3ac 100644 --- a/common/lc_timelinewidget.cpp +++ b/common/lc_timelinewidget.cpp @@ -567,14 +567,14 @@ void lcTimelineWidget::dropEvent(QDropEvent* Event) QList SelectedItems = selectedItems(); clearSelection(); - if (DropItem) - { - QTreeWidgetItem* ParentItem = DropItem->parent(); - lcStep Step = indexOfTopLevelItem(ParentItem ? ParentItem : DropItem) + 1; + if (!DropItem) + return; - if (Step > Model->GetCurrentStep()) - Model->SetCurrentStep(Step); - } + QTreeWidgetItem* ParentItem = DropItem->parent(); + lcStep Step = indexOfTopLevelItem(ParentItem ? ParentItem : DropItem) + 1; + + if (Step > Model->GetCurrentStep()) + Model->SetCurrentStep(Step); auto SortItems = [this](QTreeWidgetItem* Item1, QTreeWidgetItem* Item2) {