timeline: add null check

This commit is contained in:
itsmattkc
2021-09-27 11:05:35 -07:00
parent b3566f9420
commit 407407491f
+5 -1
View File
@@ -721,10 +721,13 @@ void PointerTool::InitiateDrag(Block *clicked_item,
TimelineViewGhostItem* PointerTool::AddGhostFromBlock(Block* block, Timeline::MovementMode mode, bool check_if_exists)
{
if (!block) {
// Ignore null blocks or blocks that aren't attached to a track because there's nothing we can
// do with either of those
if (!block || !block->track()) {
return nullptr;
}
// Check if we've already made a ghost for this block
if (check_if_exists) {
foreach (TimelineViewGhostItem* ghost, parent()->GetGhostItems()) {
if (Node::ValueToPtr<Block>(ghost->GetData(TimelineViewGhostItem::kAttachedBlock)) == block) {
@@ -733,6 +736,7 @@ TimelineViewGhostItem* PointerTool::AddGhostFromBlock(Block* block, Timeline::Mo
}
}
// Otherwise, it's time to make a ghost for this block
TimelineViewGhostItem* ghost = TimelineViewGhostItem::FromBlock(block);
#ifdef HIDE_GAP_GHOSTS