Skip to content

Commit

Permalink
Disable autosave
Browse files Browse the repository at this point in the history
Not worth the problems it causes
  • Loading branch information
gr455 committed Apr 20, 2024
1 parent 4633151 commit 25f0226
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
7 changes: 7 additions & 0 deletions simulator/src/data/backupCircuit.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export function checkIfBackup(scope) {

export function backUp(scope = globalScope) {

// Disconnection of subcircuits are needed because these are the connections between nodes
// in current scope and those in the subcircuit's scope
for (let i = 0; i < scope.SubCircuit.length; i++) { scope.SubCircuit[i].removeConnections(); }

var data = {};

// Storing layout
Expand Down Expand Up @@ -48,6 +52,9 @@ export function backUp(scope = globalScope) {
data.nodes = [];
for (let i = 0; i < scope.nodes.length; i++) { data.nodes.push(scope.allNodes.indexOf(scope.nodes[i])); }

// Restoring the connections
for (let i = 0; i < scope.SubCircuit.length; i++) { scope.SubCircuit[i].makeConnections(); }

return data;
}

Expand Down
7 changes: 4 additions & 3 deletions simulator/src/data/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ export function generateSaveData(name, setName = true) {
// to circuits where this circuit is used as a subcircuit. It will
// break the code since the Subcircuit will have different number of
// in/out nodes compared to the localscope input/output objects.
updateSubcircuitSet(true);
update(scopeList[id]); // For any pending integrity checks on subcircuits
update(scopeList[id], true); // For any pending integrity checks on subcircuits
data.scopes.push(backUp(scopeList[id]));
}

Expand Down Expand Up @@ -435,4 +434,6 @@ export function checkBackups() {
}
}

setInterval(checkBackups, 3000);
// Please do not enable autosave. It will not work
// in the current state and breaks other things.
// setInterval(checkBackups, 3000); // disabled
4 changes: 1 addition & 3 deletions simulator/src/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,7 @@ export default class Node {
connections: [],
};
for (var i = 0; i < this.connections.length; i++) {
// For connections from scope.Subcircuit.node to localscope.input/output.node
// these connections should be ignored while saving.
if (this.connections[i].scope != this.scope) continue;

data.connections.push(findNode(this.connections[i]));
}
return data;
Expand Down
9 changes: 4 additions & 5 deletions simulator/src/subcircuit.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,13 +471,12 @@ export default class SubCircuit extends CircuitElement {
// console.log(subcircuitScope.name, subcircuitScope.timeStamp, this.lastUpdated)
if (subcircuitScope.timeStamp > this.lastUpdated) {
this.reBuildCircuit();
// console.log("rebuild called")
this.localScope.reset();
updateSimulationSet(true);
// Why is forceResetNodes required here?
forceResetNodesSet(true);
}

this.localScope.reset();
updateSimulationSet(true);
forceResetNodesSet(true);

this.makeConnections();
}

Expand Down

0 comments on commit 25f0226

Please sign in to comment.