Skip to content

Commit 10d099c

Browse files
author
lee.hungyu
committed
함수 삭제하고 파이썬으로 변경되도록 추가
1 parent 52a9370 commit 10d099c

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/class/variable_container.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,6 +1507,24 @@ Entry.VariableContainer = class VariableContainer {
15071507
this.updateList();
15081508
}
15091509

1510+
removeNotPythonSupportedFunction() {
1511+
const functions = this.functions_;
1512+
Object.values(functions).forEach((func) => {
1513+
const isNotPythonSupport = func.useLocalVariables || func.type === 'value';
1514+
if (isNotPythonSupport) {
1515+
const functionId = func.id;
1516+
func.destroy();
1517+
delete functions[functionId];
1518+
const functionType = `func_${functionId}`;
1519+
Entry.container.removeFuncBlocks(functionType);
1520+
for (const id in functions) {
1521+
functions[id].content.removeBlocksByType(functionType);
1522+
}
1523+
}
1524+
});
1525+
this.updateList();
1526+
}
1527+
15101528
checkListPosition(list, mouse) {
15111529
const pos = {
15121530
start_w: list.x_,

src/playground/workspace.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,17 @@ Entry.Workspace = class Workspace {
198198
if (alertMessage.type === 'warning') {
199199
Entry.modal.confirm(alertMessage.message).then((result) => {
200200
if (result) {
201+
Entry.variableContainer.removeNotPythonSupportedFunction();
201202
Entry.expansion.banExpansionBlocks(Entry.expansionBlocks);
202203
Entry.aiUtilize.banAIUtilizeBlocks(Entry.aiUtilizeBlocks);
203204
Entry.hwLite.banClassAllHardwareLite();
204205
Entry.playground.dataTable.removeAllBlocks();
205206
Entry.aiLearning.removeAllBlocks();
206-
changeToPythonMode();
207-
dispatchChangeBoardEvent();
207+
// 블럭 삭제되고 처리
208+
requestAnimationFrame(() => {
209+
changeToPythonMode();
210+
dispatchChangeBoardEvent();
211+
});
208212
} else {
209213
const mode = {};
210214
mode.boardType = WORKSPACE.MODE_BOARD;

0 commit comments

Comments
 (0)