Commit 7e4e6e00 authored by Evan W. Patton's avatar Evan W. Patton

Defer loading of screens until after Screen1 loads

When importing a project that requires an upgrade involving project
settings, if any screen loaded before Screen1 would fail to
upgrade. Attempting to build a project in this state would only
generate YAIL files for the successfully loaded screens. The build
server would attempt to generate YAIL for the missing screens using
the AI1 YAIL generator, which no longer exists. The error message
doesn't give any indication that this is the problem.

This change defers loading of screens other than Screen1 until
Screen1's form is loaded. At this point the upgrade of the Form and
the project settings will have occurred, and then we can proceed to
load the additional screens.

Change-Id: Ibde055171a8939a9e9ae5ed8ea5ce3954fb5ccf1
parent 0166242c
......@@ -40,6 +40,7 @@ import com.google.appinventor.shared.storage.StorageUtil;
import com.google.appinventor.shared.youngandroid.YoungAndroidSourceAnalyzer;
import com.google.common.collect.Maps;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.RepeatingCommand;
import com.google.gwt.json.client.JSONException;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.rpc.AsyncCallback;
......@@ -405,7 +406,7 @@ public final class YaProjectEditor extends ProjectEditor implements ProjectChang
editors.formEditor = newFormEditor;
editorMap.put(formName, editors);
}
newFormEditor.loadFile(new Command() {
final Command afterLoadCommand = new Command() {
@Override
public void execute() {
int pos = Collections.binarySearch(fileIds, newFormEditor.getFileId(),
......@@ -417,7 +418,7 @@ public final class YaProjectEditor extends ProjectEditor implements ProjectChang
if (isScreen1(formName)) {
screen1FormLoaded = true;
if (readyToShowScreen1()) {
OdeLog.log("YaProjectEditor.addFormEditor.loadFile.execute: switching to screen "
OdeLog.log("YaProjectEditor.addFormEditor.loadFile.execute: switching to screen "
+ formName + " for project " + newFormEditor.getProjectId());
Ode.getInstance().getDesignToolbar().switchToScreen(newFormEditor.getProjectId(),
formName, DesignToolbar.View.FORM);
......@@ -425,7 +426,24 @@ public final class YaProjectEditor extends ProjectEditor implements ProjectChang
}
loadBlocksEditor(formName);
}
});
};
if (!isScreen1(formName) && !screen1FormLoaded) {
// Defer loading other screens until Screen1 is loaded. Otherwise we can end up in an
// inconsistent state during project upgrades with Screen1-only properties.
Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
@Override
public boolean execute() {
if (screen1FormLoaded) {
newFormEditor.loadFile(afterLoadCommand);
return false;
} else {
return true;
}
}
}, 100);
} else {
newFormEditor.loadFile(afterLoadCommand);
}
}
private boolean readyToShowScreen1() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment