Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/HandledContributionItem.java7
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/PartRenderingEngine.java25
2 files changed, 25 insertions, 7 deletions
diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/HandledContributionItem.java b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/HandledContributionItem.java
index c0f314d7c92..4cf7674f45b 100644
--- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/HandledContributionItem.java
+++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/HandledContributionItem.java
@@ -213,8 +213,11 @@ public class HandledContributionItem extends ContributionItem {
if (updateRunner == null) {
updateRunner = new ISafeRunnable() {
public void run() throws Exception {
- model.setEnabled(canExecuteItem(null));
- update();
+ boolean shouldEnable = canExecuteItem(null);
+ if (shouldEnable != model.isEnabled()) {
+ model.setEnabled(shouldEnable);
+ update();
+ }
}
public void handleException(Throwable exception) {
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/PartRenderingEngine.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/PartRenderingEngine.java
index 1fbc7514ded..b3e7316df34 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/PartRenderingEngine.java
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/PartRenderingEngine.java
@@ -1039,8 +1039,7 @@ public class PartRenderingEngine implements IPresentationEngine {
}
// Spin the event loop until someone disposes the display
while (((testShell != null && !testShell.isDisposed()) || (theApp != null
- && !theApp.getChildren().isEmpty() && someAreVisible(theApp
- .getChildren()))) && !display.isDisposed()) {
+ && someAreVisible(theApp.getChildren()))) && !display.isDisposed()) {
try {
if (!display.readAndDispatch()) {
runContext.processWaiting();
@@ -1079,9 +1078,25 @@ public class PartRenderingEngine implements IPresentationEngine {
}
protected boolean someAreVisible(List<MWindow> windows) {
- for (MWindow win : windows) {
- if (win.isToBeRendered() && win.isVisible()
- && win.getWidget() != null) {
+ // This method is called from the event dispatch loop, so the
+ // following optimization is in order...
+
+ // Ideally, we'd just do:
+ // for (MWindow win : theApp.getChildren()) {
+ // But this creates an iterator (which must be GC'd)
+ // at every call. The code below creates no objects.
+ final int limit = windows.size();
+ for (int i = 0; i < limit; i++) {
+ final MWindow win = windows.get(i);
+ // Note: Removed isVisible test, as this should have
+ // no impact on the whether the event loop
+ // terminates - non-visible windows still exists
+ // and can receive events.
+ // Note: isToBeRendered() == true => win.getWidget() != null
+ // but I'm not sure whether there is latency between setting
+ // toBeRendered and the creation of the widget. So, keeping
+ // both tests seems prudent.
+ if (win.isToBeRendered() && win.getWidget() != null) {
return true;
}
}

Back to the top