Skip to content

Commit

Permalink
Fix wrong input/output - labels loading at top module when open a sub…
Browse files Browse the repository at this point in the history
…module (thanks Demócrito)
  • Loading branch information
cavearr committed Nov 7, 2024
1 parent dbe333a commit 47183f1
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 10 deletions.
3 changes: 1 addition & 2 deletions app/resources/libs/Icestudio/Fuse/IceHD.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class IceHD {
// Is file
basen = (b.indexOf('.') < 0) ? b : b.substr(0, b.lastIndexOf('.'));
}
console.log(basen);
return basen;
}

Expand Down Expand Up @@ -137,4 +136,4 @@ class IceHD {
});
}

}
}
3 changes: 2 additions & 1 deletion app/scripts/services/blockforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ angular.module('icestudio')

switch (instance.type) {
case blocks.BASIC_INPUT:
return loadBasicInput(instance, disabled);
return loadBasicInput(instance, disabled);

case blocks.BASIC_OUTPUT:
return loadBasicOutput(instance, disabled);
Expand Down Expand Up @@ -794,6 +794,7 @@ angular.module('icestudio')
var topPorts = [];
var bottomPorts = [];
let virtualBlock = new IceBlock({ cacheDirImg: common.IMAGE_CACHE_DIR });

instance.data = { ports: { in: [] } };

for (i in block.design.graph.blocks) {
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/services/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,6 @@ angular.module('icestudio')
commandManager.stopListening();

self.clearAll();

let cells = graphToCells(design.graph, opt);

self.fitContent();
Expand Down Expand Up @@ -1572,7 +1571,7 @@ angular.module('icestudio')
_.each(_graph.blocks, function (blockInstance) {


if (blockInstance.type !== false && blockInstance.type.indexOf('basic.') !== -1) {
if (blockInstance.type !== false && blockInstance.type.indexOf('basic.') >-1) {
if (opt.reset &&
(blockInstance.type === blocks.BASIC_INPUT ||
blockInstance.type === blocks.BASIC_OUTPUT)) {
Expand Down Expand Up @@ -1616,6 +1615,7 @@ angular.module('icestudio')
}

}

cell = blockforms.loadBasic(blockInstance, opt.disabled);
}
else {
Expand Down
36 changes: 32 additions & 4 deletions app/scripts/services/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,44 @@ angular.module('icestudio')
});
};

this.adaptToTheTop= function(data){
data.design.graph.blocks.forEach(block => {
switch (block.type) {
case blocks.BASIC_INPUT:
case blocks.BASIC_OUTPUT:
case blocks.BASIC_OUTPUT_LABEL:
case blocks.BASIC_INPUT_LABEL:

if (typeof block.data.virtual === 'undefined') {
block.data.virtual=true;
block.data.pins= [{
index: 0,
name: null,
value: null
}];

}
break;
}

});
return data;


};

this.load = function (name, data) {
var self = this;
if (!checkVersion(data.version)) {
utils.endBlockingTask();
return;
}

data = this.adaptToTheTop(data);
project = _safeUpgradeVersion(data, name);
utils.approveProjectBlock(profile, project, true).then((result) => {

utils.approveProjectBlock(profile, project, true).then((result) => {
if (result === 'cancel') {
console.log('cancelLoad');
utils.endBlockingTask();
return;
}
Expand Down Expand Up @@ -200,8 +227,8 @@ angular.module('icestudio')
switch (data.version) {
case common.VERSION:
case '1.1':
project = data;
break;
project = data;
break;
case '1.0':
project = convert10To12(data);
break;
Expand Down Expand Up @@ -353,6 +380,7 @@ angular.module('icestudio')
var name = utils.basename(filepath);

if (subModuleActive) {

backupProject = utils.clone(project);

} else {
Expand Down
1 change: 0 additions & 1 deletion app/scripts/services/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,6 @@ angular.module('icestudio')

// Update dependencies
if (opt.deps !== false) {
console.log('DEPS',opt);
var types = this.findSubDependencies(p, common.allDependencies);
for (var t in types) {
p.dependencies[types[t]] = common.allDependencies[types[t]];
Expand Down

0 comments on commit 47183f1

Please sign in to comment.