From 4c965cf5eb2947fd62c1e7b70351add9bdd5c157 Mon Sep 17 00:00:00 2001
From: jsiegle <jsiegle@mit.edu>
Date: Wed, 22 Jan 2014 20:27:17 -0500
Subject: [PATCH] Fix crash when deleting complex signal chains

---
 Source/UI/EditorViewport.cpp | 17 ++++++++++-------
 Source/UI/UIComponent.cpp    |  2 ++
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/Source/UI/EditorViewport.cpp b/Source/UI/EditorViewport.cpp
index 660135135..eedb242a7 100755
--- a/Source/UI/EditorViewport.cpp
+++ b/Source/UI/EditorViewport.cpp
@@ -139,13 +139,13 @@ void EditorViewport::paint(Graphics& g)
     //int w = 30;
     //int h = getHeight() - 2*(borderSize+2);
 
-    if (editorArray.size() > 0)
-    {
-        if (!editorArray[0]->getProcessor()->isSource())
-            g.drawImageAt(sourceDropImage, x, y);
-    } else {
+    //if (editorArray.size() > 0)
+    //{
+        //if (!editorArray[0]->getProcessor()->isSource())
+    //    g.drawImageAt(sourceDropImage, x, y);
+    //} else {
         g.drawImageAt(sourceDropImage, x, y);
-    }
+    //}
 }
 
 bool EditorViewport::isInterestedInDragSource(const SourceDetails& dragSourceDetails)
@@ -279,8 +279,11 @@ void EditorViewport::itemDropped(const SourceDetails& dragSourceDetails)
 
 void EditorViewport::clearSignalChain()
 {
+
     if (canEdit)
     {
+        editorArray.clear();
+        //const MessageManagerLock mmLock; // prevent redraw while deleting
         std::cout << "Clearing signal chain." << std::endl;
         signalChainManager->clearSignalChain();
         getProcessorGraph()->clearSignalChain();
@@ -294,7 +297,7 @@ void EditorViewport::clearSignalChain()
 
     }
 
-    //repaint();
+    repaint();
 }
 
 void EditorViewport::makeEditorVisible(GenericEditor* editor, bool highlight, bool updateSettings)
diff --git a/Source/UI/UIComponent.cpp b/Source/UI/UIComponent.cpp
index 5811e0649..767ad9277 100755
--- a/Source/UI/UIComponent.cpp
+++ b/Source/UI/UIComponent.cpp
@@ -439,8 +439,10 @@ bool UIComponent::perform(const InvocationInfo& info)
                 break;
             }
         case clearSignalChain:
+        {
             getEditorViewport()->clearSignalChain();
             break;
+        }
 
         case showHelp:
             std::cout << "SHOW ME SOME HELP!" << std::endl;
-- 
GitLab