Skip to content

Commit 0522004

Browse files
committed
Fix splitter attaching first processor to second branch causing errors
Stop saving state to recoveryConfig while loading config on startup
1 parent be5c2e4 commit 0522004

5 files changed

Lines changed: 36 additions & 18 deletions

File tree

Source/MainWindow.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383

8484
if(lastConfig.existsAsFile())
8585
{
86+
std::cout << "Comparing configs" << std::endl;
8687
if(compareConfigFiles(lastConfig, recoveryConfig))
8788
{
8889
ui->getEditorViewport()->loadState(lastConfig);
@@ -282,6 +283,7 @@ bool MainWindow::compareConfigFiles(File file1, File file2)
282283
if(rcXml == 0 || ! rcXml->hasTagName("SETTINGS"))
283284
{
284285
std::cout << "Recovery config is inavlid. Loading lastConfig.xml" << std::endl;
286+
return true;
285287
}
286288

287289
auto lcSig = lcXml->getChildByName("SIGNALCHAIN");

Source/Processors/Editors/GenericEditor.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -554,9 +554,13 @@ void GenericEditor::update()
554554

555555
updateVisualizer(); // does nothing unless this method
556556
// has been implemented
557-
558-
File recoveryFile = CoreServices::getSavedStateDirectory().getChildFile("recoveryConfig.xml");
559-
AccessClass::getEditorViewport()->saveState(recoveryFile);
557+
558+
EditorViewport* ev = AccessClass::getEditorViewport();
559+
if(!ev->loadingConfig)
560+
{
561+
File recoveryFile = CoreServices::getSavedStateDirectory().getChildFile("recoveryConfig.xml");
562+
ev->saveState(recoveryFile);
563+
}
560564

561565
}
562566

Source/UI/EditorViewport.cpp

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ EditorViewport::EditorViewport()
3737
somethingIsBeingDraggedOver(false), shiftDown(false), canEdit(true),
3838
lastEditorClicked(0), selectionIndex(0), borderSize(6), tabSize(30),
3939
tabButtonSize(15), insertionPoint(0), componentWantsToMove(false),
40-
indexOfMovingComponent(-1), currentTab(-1)
40+
indexOfMovingComponent(-1), currentTab(-1), loadingConfig(false)
4141
{
4242

4343
addMouseListener(this, true);
@@ -1159,7 +1159,7 @@ XmlElement* EditorViewport::createNodeXml(GenericProcessor* source)
11591159

11601160
name += source->getEditor()->getName();
11611161

1162-
std::cout << name << std::endl;
1162+
//std::cout << name << std::endl;
11631163

11641164
e->setAttribute("name", name);
11651165
e->setAttribute("insertionPoint", 1);
@@ -1172,7 +1172,7 @@ XmlElement* EditorViewport::createNodeXml(GenericProcessor* source)
11721172
e->setAttribute("isSink", source->isSink());
11731173

11741174
/**Saves individual processor parameters to XML */
1175-
std::cout << "Create subnodes with parameters" << std::endl;
1175+
//std::cout << "Create subnodes with parameters" << std::endl;
11761176
source->saveToXml(e);
11771177

11781178
return e;
@@ -1221,6 +1221,7 @@ const String EditorViewport::saveState(File fileToUse, String* xmlText)
12211221
// }
12221222

12231223
Array<GenericProcessor*> splitPoints;
1224+
Array<GenericProcessor*> allSplitters;
12241225
/** Used to reset saveOrder at end, to allow saving the same processor multiple times*/
12251226
Array<GenericProcessor*> allProcessors;
12261227

@@ -1261,6 +1262,7 @@ const String EditorViewport::saveState(File fileToUse, String* xmlText)
12611262
{
12621263
// add to list of splitters to come back to
12631264
splitPoints.add(processor);
1265+
allSplitters.add(processor);
12641266
processor->switchIO(0);
12651267
}
12661268

@@ -1271,20 +1273,16 @@ const String EditorViewport::saveState(File fileToUse, String* xmlText)
12711273
saveOrder++;
12721274

12731275
}
1274-
else
1275-
{
1276-
std::cout << " Processor already saved as number " << processor->saveOrder << std::endl;
1277-
}
12781276

12791277
// continue until the end of the chain
1280-
std::cout << " Moving forward along signal chain." << std::endl;
1278+
//std::cout << " Moving forward along signal chain." << std::endl;
12811279
processor = processor->getDestNode();
12821280

12831281
if (processor == nullptr)
12841282
{
12851283
if (splitPoints.size() > 0)
12861284
{
1287-
std::cout << " Going back to first unswitched splitter." << std::endl;
1285+
//std::cout << " Going back to first unswitched splitter." << std::endl;
12881286

12891287
processor = splitPoints.getFirst();
12901288
splitPoints.remove(0);
@@ -1294,10 +1292,14 @@ const String EditorViewport::saveState(File fileToUse, String* xmlText)
12941292
}
12951293
else
12961294
{
1297-
std::cout << " End of chain." << std::endl;
1295+
//std::cout << " End of chain." << std::endl;
12981296
}
12991297
}
13001298
}
1299+
1300+
for (GenericProcessor* sp : allSplitters) {
1301+
sp->switchIO(0);
1302+
}
13011303

13021304
xml->addChildElement(signalChain);
13031305
}
@@ -1452,7 +1454,8 @@ const String EditorViewport::loadState(File fileToLoad)
14521454
return "Failed To Open " + fileToLoad.getFileName();
14531455
}
14541456
clearSignalChain();
1455-
1457+
1458+
loadingConfig = true; //Indicate config is being loaded into the GUI
14561459
String description;// = " ";
14571460
int loadOrder = 0;
14581461

@@ -1620,7 +1623,9 @@ const String EditorViewport::loadState(File fileToLoad)
16201623
delete xml;
16211624

16221625
currentId=maxID+1; // make sure future processors don't have overlapping id numbers
1623-
1626+
1627+
loadingConfig = false;
1628+
16241629
return error;
16251630
}
16261631
/* Set parameters based on XML.*/

Source/UI/EditorViewport.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ class EditorViewport : public Component,
174174
int leftmostEditor;
175175

176176
File currentFile;
177+
178+
// Flag to check whether config is being loaded currently
179+
bool loadingConfig;
177180

178181
private:
179182

Source/UI/SignalChainManager.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,11 @@ void SignalChainManager::updateProcessorSettings()
575575
}
576576
}
577577
}
578-
579-
File recoveryFile = CoreServices::getSavedStateDirectory().getChildFile("recoveryConfig.xml");
580-
AccessClass::getEditorViewport()->saveState(recoveryFile);
578+
579+
EditorViewport* ev = AccessClass::getEditorViewport();
580+
if(!ev->loadingConfig)
581+
{
582+
File recoveryFile = CoreServices::getSavedStateDirectory().getChildFile("recoveryConfig.xml");
583+
ev->saveState(recoveryFile);
584+
}
581585
}

0 commit comments

Comments
 (0)