Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/class/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,9 @@ Entry.EntityObject = class EntityObject {
* @param {?picture model} pictureModel
*/
setImage(pictureModel) {
if (!pictureModel) {
return;
}
const that = this;
delete pictureModel._id;

Expand Down
10 changes: 8 additions & 2 deletions src/playground/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,10 +490,16 @@ Entry.Code = class Code {
this.destroyView();
}

static waitPauseState = async () => {
while (Entry.engine.isState('pause')) {
await Entry.Utils.sleep(100);
}
};

static funcAsyncExecute = async (funcCode, funcExecutor, _promises = []) => {
await Promise.all(_promises);
if (Entry.engine.isState('pause')) {
return this.funcAsyncExecute(funcCode, funcExecutor, _promises);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kimorkim
무한대기가 끝난 이후에 다시 funcAsyncExecute을 실행하는 부분은 필요가 없는 건가요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tnks2U
해당코드가 그 밑의

return new Promise((resolve, reject) => {

부분을 호출하는 것과 동일한것으로 여겨서 제외했는데. 이제 보니 run 체크 하는걸 한번더 하는게 나아 보이네요. 살려 두는게 좀더 실용적 이겠네요.

await this.waitPauseState();
} else if (!Entry.engine.isState('run')) {
funcCode.removeExecutor(funcExecutor);
return Entry.STATIC.BREAK;
Expand Down Expand Up @@ -538,7 +544,7 @@ Entry.Code = class Code {
static funcValueAsyncExecute = async (funcCode, funcExecutor, _promises = []) => {
await Promise.all(_promises);
if (Entry.engine.isState('pause')) {
return this.funcValueAsyncExecute(funcCode, funcExecutor, _promises);
await this.waitPauseState();
} else if (!Entry.engine.isState('run')) {
funcCode.removeExecutor(funcExecutor);
return await this.getAsyncParamsData(funcExecutor.result);
Expand Down
9 changes: 5 additions & 4 deletions src/util/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2756,7 +2756,9 @@ Entry.Utils.pauseSoundInstances = function () {
Entry.Utils.recoverSoundInstances = function () {
Entry.soundInstances.getAllValues().forEach((instance) => {
instance.paused = false;
instance.sourceNode.playbackRate.value = Entry.playbackRateValue;
if (instance.sourceNode?.playbackRate) {
instance.sourceNode.playbackRate.value = Entry.playbackRateValue;
}
});
Entry.bgmInstances.getAllValues().forEach((instance) => {
instance.paused = false;
Expand Down Expand Up @@ -2964,11 +2966,10 @@ Entry.Utils.removeBlockByType2 = function (blockType, callback) {
}
};

Entry.Utils.sleep = (time = 0) => {
return new Promise((resolve) => {
Entry.Utils.sleep = (time = 0) =>
new Promise((resolve) => {
setTimeout(resolve, time);
});
};

Entry.Utils.runAsync = async (func) => {
await Entry.Utils.sleep();
Expand Down