nodeparamview: fixed problematic behavior

Fixes #1894
This commit is contained in:
itsmattkc
2022-04-11 11:06:51 -07:00
parent 5afd322644
commit e85a5b21b0
2 changed files with 23 additions and 20 deletions
+22 -19
View File
@@ -405,13 +405,13 @@ void NodeParamView::RemoveContext(Node *ctx)
disconnect(ctx, &Node::NodeAddedToContext, this, &NodeParamView::NodeAddedToContext);
disconnect(ctx, &Node::NodeRemovedFromContext, this, &NodeParamView::NodeRemovedFromContext);
NodeParamViewContext *item = GetContextItemFromContext(ctx);
foreach (NodeParamViewContext *item, context_items_) {
item->RemoveContext(ctx);
item->RemoveNodesWithContext(ctx);
item->RemoveContext(ctx);
item->RemoveNodesWithContext(ctx);
if (item->GetContexts().isEmpty()) {
item->setVisible(false);
if (item->GetContexts().isEmpty()) {
item->setVisible(false);
}
}
}
@@ -454,25 +454,28 @@ void NodeParamView::AddNode(Node *n, Node *ctx, NodeParamViewContext *context)
void NodeParamView::RemoveNode(Node *n, Node *ctx)
{
NodeParamViewContext *ctx_item = GetContextItemFromContext(ctx);
NodeParamViewItem *item = ctx_item->GetItem(n, ctx);
foreach (NodeParamViewContext *ctx_item, context_items_) {
NodeParamViewItem *item = ctx_item->GetItem(n, ctx);
if (focused_node_ == item) {
focused_node_ = nullptr;
emit FocusedNodeChanged(nullptr);
}
if (item) {
if (focused_node_ == item) {
focused_node_ = nullptr;
emit FocusedNodeChanged(nullptr);
}
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 (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);
ctx_item->RemoveNode(n, ctx);
}
}
int GetDistanceBetweenNodes(Node *start, Node *end)
@@ -47,7 +47,7 @@ NodeParamViewContext::NodeParamViewContext(QWidget *parent) :
NodeParamViewItem *NodeParamViewContext::GetItem(Node *node, Node *ctx)
{
for (auto it=items_.begin(); it!=items_.end(); ) {
for (auto it=items_.begin(); it!=items_.end(); it++) {
NodeParamViewItem *item = *it;
if (item->GetNode() == node && item->GetContext() == ctx) {