nodeparamview: fixed crash caused by closing contexts

This commit is contained in:
itsmattkc
2022-04-25 14:00:21 -07:00
parent fb53931f68
commit 4536ed87a5
2 changed files with 13 additions and 24 deletions
+13 -22
View File
@@ -283,6 +283,16 @@ void NodeParamView::UpdateContexts()
void NodeParamView::ItemAboutToBeRemoved(NodeParamViewItem *item)
{
if (keyframe_view_) {
for (auto it=item->GetKeyframeConnections().begin(); it!=item->GetKeyframeConnections().end(); it++) {
for (auto jt=it->begin(); jt!=it->end(); jt++) {
for (auto kt=jt->begin(); kt!=jt->end(); kt++) {
keyframe_view_->RemoveKeyframesOfTrack(*kt);
}
}
}
}
if (focused_node_ == item) {
focused_node_ = nullptr;
emit FocusedNodeChanged(nullptr);
@@ -455,27 +465,6 @@ void NodeParamView::AddNode(Node *n, Node *ctx, NodeParamViewContext *context)
}
}
void NodeParamView::RemoveNode(Node *n, Node *ctx)
{
foreach (NodeParamViewContext *ctx_item, context_items_) {
NodeParamViewItem *item = ctx_item->GetItem(n, ctx);
if (item) {
if (keyframe_view_) {
for (auto it=item->GetKeyframeConnections().begin(); it!=item->GetKeyframeConnections().end(); it++) {
for (auto jt=it->begin(); jt!=it->end(); jt++) {
for (auto kt=jt->begin(); kt!=jt->end(); kt++) {
keyframe_view_->RemoveKeyframesOfTrack(*kt);
}
}
}
}
}
ctx_item->RemoveNode(n, ctx);
}
}
int GetDistanceBetweenNodes(Node *start, Node *end)
{
if (start == end) {
@@ -675,7 +664,9 @@ void NodeParamView::NodeRemovedFromContext(Node *n)
{
Node *ctx = static_cast<Node*>(sender());
RemoveNode(n, ctx);
foreach (NodeParamViewContext *ctx_item, context_items_) {
ctx_item->RemoveNode(n, ctx);
}
if (keyframe_view_) {
QueueKeyframePositionUpdate();
-2
View File
@@ -99,8 +99,6 @@ private:
void AddNode(Node* n, Node *ctx, NodeParamViewContext *context);
void RemoveNode(Node *n, Node *ctx);
void SortItemsInContext(NodeParamViewContext *context);
NodeParamViewContext *GetContextItemFromContext(Node *context);