Browse Source

Fix for #4632 - isActive should wait for DeferredCommands to finish executing

svn changeset:16100/svn branch:6.5
tags/6.7.0.beta1
Artur Signell 13 years ago
parent
commit
a8219f8bbb

+ 5
- 0
src/com/vaadin/terminal/gwt/DefaultWidgetSet.gwt.xml View File

@@ -12,6 +12,11 @@

<source path="client" />

<!-- Use own Scheduler implementation to be able to track if commands are running -->
<replace-with class="com.vaadin.terminal.gwt.client.VSchedulerImpl">
<when-type-is class="com.google.gwt.core.client.impl.SchedulerImpl" />
</replace-with>

<!-- Use our own history impl for IE to workaround #2931. -->
<replace-with class="com.vaadin.terminal.gwt.client.HistoryImplIEVaadin">
<when-type-is class="com.google.gwt.user.client.impl.HistoryImpl" />

+ 6
- 26
src/com/vaadin/terminal/gwt/client/ApplicationConnection.java View File

@@ -138,13 +138,6 @@ public class ApplicationConnection {

private Set<Paintable> zeroHeightComponents = null;

/**
* Keeps track of if there are (potentially) deferred commands that are
* being executed. 0 == no deferred commands currently in progress, > 0
* otherwise.
*/
private int deferredCommandTrackers = 0;

public ApplicationConnection() {
view = GWT.create(VView.class);
}
@@ -650,24 +643,6 @@ public class ApplicationConnection {
}
}
});
addDeferredCommandTracker();
}

/**
* Adds a deferred command tracker. Increments the tracker count when called
* and decrements in a deferred command that is executed after all other
* deferred commands have executed.
*
*/
private void addDeferredCommandTracker() {
deferredCommandTrackers++;
Scheduler.get().scheduleDeferred(new Command() {

public void execute() {
deferredCommandTrackers--;
}

});
}

/**
@@ -768,7 +743,12 @@ public class ApplicationConnection {
* otherwise
*/
private boolean isExecutingDeferredCommands() {
return (deferredCommandTrackers > 0);
Scheduler s = Scheduler.get();
if (s instanceof VSchedulerImpl) {
return ((VSchedulerImpl) s).hasWorkQueued();
} else {
return false;
}
}

/**

+ 29
- 0
src/com/vaadin/terminal/gwt/client/VSchedulerImpl.java View File

@@ -0,0 +1,29 @@
package com.vaadin.terminal.gwt.client;
import com.google.gwt.core.client.impl.SchedulerImpl;
public class VSchedulerImpl extends SchedulerImpl {
/**
* Keeps track of if there are deferred commands that are being executed. 0
* == no deferred commands currently in progress, > 0 otherwise.
*/
private int deferredCommandTrackers = 0;
@Override
public void scheduleDeferred(ScheduledCommand cmd) {
deferredCommandTrackers++;
super.scheduleDeferred(cmd);
super.scheduleDeferred(new ScheduledCommand() {
public void execute() {
deferredCommandTrackers--;
}
});
}
public boolean hasWorkQueued() {
boolean hasWorkQueued = (deferredCommandTrackers != 0);
return hasWorkQueued;
}
}

Loading…
Cancel
Save