aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur.signell@itmill.com>2010-11-23 09:00:24 +0000
committerArtur Signell <artur.signell@itmill.com>2010-11-23 09:00:24 +0000
commita8219f8bbba83fc7c279631da9f3683e738e5df4 (patch)
tree8d90086118371974365abfd528500c590dc6490a
parent3435f85b481dd346d7946112888b8b40623de643 (diff)
downloadvaadin-framework-a8219f8bbba83fc7c279631da9f3683e738e5df4.tar.gz
vaadin-framework-a8219f8bbba83fc7c279631da9f3683e738e5df4.zip
Fix for #4632 - isActive should wait for DeferredCommands to finish executing
svn changeset:16100/svn branch:6.5
-rw-r--r--src/com/vaadin/terminal/gwt/DefaultWidgetSet.gwt.xml5
-rwxr-xr-xsrc/com/vaadin/terminal/gwt/client/ApplicationConnection.java32
-rw-r--r--src/com/vaadin/terminal/gwt/client/VSchedulerImpl.java29
3 files changed, 40 insertions, 26 deletions
diff --git a/src/com/vaadin/terminal/gwt/DefaultWidgetSet.gwt.xml b/src/com/vaadin/terminal/gwt/DefaultWidgetSet.gwt.xml
index 20db1721e6..929d35f364 100644
--- a/src/com/vaadin/terminal/gwt/DefaultWidgetSet.gwt.xml
+++ b/src/com/vaadin/terminal/gwt/DefaultWidgetSet.gwt.xml
@@ -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" />
diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
index 7f0f5529fb..7f72e745a9 100755
--- a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
+++ b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
@@ -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;
+ }
}
/**
diff --git a/src/com/vaadin/terminal/gwt/client/VSchedulerImpl.java b/src/com/vaadin/terminal/gwt/client/VSchedulerImpl.java
new file mode 100644
index 0000000000..2b7f12e105
--- /dev/null
+++ b/src/com/vaadin/terminal/gwt/client/VSchedulerImpl.java
@@ -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;
+ }
+}