Skip to content
Merged
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
16 changes: 10 additions & 6 deletions CodenameOne/src/com/codename1/ui/Display.java
Original file line number Diff line number Diff line change
Expand Up @@ -1495,8 +1495,17 @@ void setCurrent(final Form newForm, boolean reverse) {
if (edt == null) {
throw new IllegalStateException("Initialize must be invoked before setCurrent!");
}
Form current = impl.getCurrentForm();

if (!isEdt()) {
// when not running callSerially executes synchronously and would recurse here forever (#4811)
if (!codenameOneRunning) {
throw new IllegalStateException("Display.setCurrent must be invoked after Codename One has started running. Call it from start() or via callSerially.");
}
callSerially(new RunnableWrapper(newForm, null, reverse));
return;
}

Form current = impl.getCurrentForm();

if (autoFoldVKBOnFormSwitch && !(newForm instanceof Dialog)) {
setShowVirtualKeyboard(false);
Expand Down Expand Up @@ -1528,11 +1537,6 @@ void setCurrent(final Form newForm, boolean reverse) {
}
}

if (!isEdt()) {
callSerially(new RunnableWrapper(newForm, null, reverse));
return;
}

if (current != null) {
if (current.isInitialized()) {
current.deinitializeImpl();
Expand Down
Loading