Skip to content

Commit

Permalink
Fix undo action when moving a source processor
Browse files Browse the repository at this point in the history
  • Loading branch information
anjaldoshi committed Nov 5, 2024
1 parent 4d03ffb commit 587b96b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
6 changes: 4 additions & 2 deletions Source/Processors/ProcessorGraph/ProcessorGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ bool ProcessorGraph::checkForNewRootNodes (GenericProcessor* processor,
{
LOGDD (" Didn't find dest node in root nodes; adding a new root.");

if (!isLoadingSignalChain && rootNodes.size() == 8)
if (! isLoadingSignalChain && rootNodes.size() == 8)
{
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon, "Signal chain error", "Maximum of 8 signal chains.");
return false;
Expand Down Expand Up @@ -482,7 +482,7 @@ bool ProcessorGraph::checkForNewRootNodes (GenericProcessor* processor,
{
LOGDD (" Has no dest node; adding.");

if (!isLoadingSignalChain && rootNodes.size() == 8)
if (! isLoadingSignalChain && rootNodes.size() == 8)
{
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon, "Signal chain error", "Maximum of 8 signal chains.");
return false;
Expand Down Expand Up @@ -993,6 +993,8 @@ void ProcessorGraph::clearSignalChain()
AccessClass::getGraphViewer()->removeAllNodes();

updateViews (nullptr);

LOGC ("Signal chain cleared.");
}

void ProcessorGraph::changeListenerCallback (ChangeBroadcaster* source)
Expand Down
32 changes: 15 additions & 17 deletions Source/Processors/ProcessorGraph/ProcessorGraphActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,29 +312,29 @@ MoveProcessor::MoveProcessor (GenericProcessor* processor,
originalSourceNodeId = -1;

if (processor->getDestNode() != nullptr)
{
originalDestNodeId = processor->getDestNode()->getNodeId();

if (processor->getDestNode()->getDestNode() != nullptr)
originalDestNodeDestNodeId = processor->getDestNode()->getDestNode()->getNodeId();
else
originalDestNodeDestNodeId = -1;
}
else
{
originalDestNodeId = -1;
originalDestNodeDestNodeId = -1;
}

if (sourceNode != nullptr)
newSourceNodeId = sourceNode->getNodeId();
else
newSourceNodeId = -1;

if (destNode != nullptr)
{
newDestNodeId = destNode->getNodeId();

if (destNode->getSourceNode() != nullptr)
newDestNodeSourceNodeId = destNode->getSourceNode()->getNodeId();
else
newDestNodeSourceNodeId = -1;
}
else
{
newDestNodeId = -1;
newDestNodeSourceNodeId = -1;
}
}

MoveProcessor::~MoveProcessor()
Expand Down Expand Up @@ -372,16 +372,14 @@ bool MoveProcessor::undo()
processorGraph->moveProcessor (processor,
sourceProcessor,
destProcessor,
moveDownstream);
! moveDownstream);

if (processor->isSource() && originalDestNodeDestNodeId > -1)
if (processor->isSource() && newDestNodeSourceNodeId > -1)
{
GenericProcessor* originalDest = processorGraph->getProcessorWithNodeId (originalDestNodeDestNodeId);
GenericProcessor* newDest = processorGraph->getProcessorWithNodeId (newDestNodeId);
GenericProcessor* newDestOrigSource = processorGraph->getProcessorWithNodeId (newDestNodeSourceNodeId);

processorGraph->moveProcessor (originalDest,
destProcessor,
originalDest->getDestNode(),
moveDownstream);
processorGraph->reconnectProcessors (newDestNodeSourceNodeId, newDestNodeId);
}

return true;
Expand Down
3 changes: 1 addition & 2 deletions Source/Processors/ProcessorGraph/ProcessorGraphActions.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ class MoveProcessor : public UndoableAction
int originalDestNodeId;
int newSourceNodeId;
int newDestNodeId;

int originalDestNodeDestNodeId;
int newDestNodeSourceNodeId;

bool moveDownstream;

Expand Down

0 comments on commit 587b96b

Please sign in to comment.