Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre-Charles David2016-11-23 14:50:15 +0000
committerMelanie Bats2016-12-02 15:13:26 +0000
commitfdb962b6df974502379a177c133b4b6c7f2eb8db (patch)
tree8607f6c6e82cc09e8cb000a500ab8307437cbb3f
parent4081d89b04ab71212cfb7c1581c3810d9a2c3755 (diff)
downloadorg.eclipse.eef-v1.8.x.tar.gz
org.eclipse.eef-v1.8.x.tar.xz
org.eclipse.eef-v1.8.x.zip
[508246] Defer image creation to workaround #265265v1.8.0_RC4v1.8.0v1.8.x
Legacy properties tabs are discovered at plug-in startup, but if this happens in a non-UI thread we should avoid allocating SWT images at that time, as under Linux it can cause deadlocks (see #265265). Bug: 508246 Change-Id: I4de08f25d6246322d0fec240db48bf2d747b52d1 Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
-rw-r--r--plugins/org.eclipse.eef.properties.ui.legacy/src/org/eclipse/eef/properties/ui/legacy/internal/EEFPropertiesUiLegacyPlugin.java1
-rw-r--r--plugins/org.eclipse.eef.properties.ui.legacy/src/org/eclipse/eef/properties/ui/legacy/internal/extension/impl/LegacyPropertyTabItemDescriptor.java32
-rw-r--r--plugins/org.eclipse.eef.properties.ui.legacy/src/org/eclipse/eef/properties/ui/legacy/internal/extension/impl/LegacyPropertyTabRegistry.java11
-rw-r--r--plugins/org.eclipse.eef.properties.ui.legacy/src/org/eclipse/eef/properties/ui/legacy/internal/extension/impl/LegacyPropertyTabsRegistryEventListener.java9
4 files changed, 43 insertions, 10 deletions
diff --git a/plugins/org.eclipse.eef.properties.ui.legacy/src/org/eclipse/eef/properties/ui/legacy/internal/EEFPropertiesUiLegacyPlugin.java b/plugins/org.eclipse.eef.properties.ui.legacy/src/org/eclipse/eef/properties/ui/legacy/internal/EEFPropertiesUiLegacyPlugin.java
index 8bc865da0..742c4b1a0 100644
--- a/plugins/org.eclipse.eef.properties.ui.legacy/src/org/eclipse/eef/properties/ui/legacy/internal/EEFPropertiesUiLegacyPlugin.java
+++ b/plugins/org.eclipse.eef.properties.ui.legacy/src/org/eclipse/eef/properties/ui/legacy/internal/EEFPropertiesUiLegacyPlugin.java
@@ -185,6 +185,7 @@ public class EEFPropertiesUiLegacyPlugin extends EMFPlugin {
registry.removeListener(this.tabbedPropertySectionsListener);
registry.removeListener(this.tabbedPropertyContributorListener);
this.tabbedPropertyTabsListener = null;
+ this.tabbedPropertyTabsRegistry.dispose();
this.tabbedPropertyTabsRegistry = null;
this.tabbedPropertySectionsListener = null;
this.tabbedPropertySectionsRegistry = null;
diff --git a/plugins/org.eclipse.eef.properties.ui.legacy/src/org/eclipse/eef/properties/ui/legacy/internal/extension/impl/LegacyPropertyTabItemDescriptor.java b/plugins/org.eclipse.eef.properties.ui.legacy/src/org/eclipse/eef/properties/ui/legacy/internal/extension/impl/LegacyPropertyTabItemDescriptor.java
index 13b9b1aac..5c97c630d 100644
--- a/plugins/org.eclipse.eef.properties.ui.legacy/src/org/eclipse/eef/properties/ui/legacy/internal/extension/impl/LegacyPropertyTabItemDescriptor.java
+++ b/plugins/org.eclipse.eef.properties.ui.legacy/src/org/eclipse/eef/properties/ui/legacy/internal/extension/impl/LegacyPropertyTabItemDescriptor.java
@@ -13,6 +13,7 @@ package org.eclipse.eef.properties.ui.legacy.internal.extension.impl;
import org.eclipse.eef.properties.ui.api.AbstractEEFTabDescriptor;
import org.eclipse.eef.properties.ui.legacy.internal.EEFPropertiesUiLegacyPlugin;
import org.eclipse.eef.properties.ui.legacy.internal.extension.IItemDescriptor;
+import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
/**
@@ -52,7 +53,14 @@ public class LegacyPropertyTabItemDescriptor extends AbstractEEFTabDescriptor im
private boolean indented;
/**
- * If an image is provided, the icon image is displayed on the tab when the tab is active.
+ * Image descriptor used to delay the actual {@link Image} creation until really needed. <code>null</code> if no
+ * image specified if it was already created (in which case the 'image' field will be non-null).
+ */
+ private ImageDescriptor imageDesc;
+
+ /**
+ * If an image is provided, the icon image is displayed on the tab when the tab is active. Only allocated on first
+ * demandn using imageDesc.
*/
private Image image;
@@ -71,11 +79,11 @@ public class LegacyPropertyTabItemDescriptor extends AbstractEEFTabDescriptor im
* The afterTab
* @param indented
* Is indented
- * @param image
- * The image
+ * @param imageDesc
+ * The image descriptor
*/
public LegacyPropertyTabItemDescriptor(String contributorId, String label, String category, String afterTab, String id, boolean indented,
- Image image) {
+ ImageDescriptor imageDesc) {
setSectionDescriptors(
EEFPropertiesUiLegacyPlugin.getImplementation().getTabbedPropertySectionsRegistry().getPropertySections(contributorId, id));
this.contributorId = contributorId;
@@ -84,7 +92,7 @@ public class LegacyPropertyTabItemDescriptor extends AbstractEEFTabDescriptor im
this.label = label;
this.afterTab = afterTab;
this.indented = indented;
- this.image = image;
+ this.imageDesc = imageDesc;
}
/**
@@ -156,6 +164,20 @@ public class LegacyPropertyTabItemDescriptor extends AbstractEEFTabDescriptor im
*/
@Override
public Image getImage() {
+ if (this.image == null && this.imageDesc != null) {
+ this.image = this.imageDesc.createImage();
+ this.imageDesc = null;
+ }
return this.image;
}
+
+ /**
+ * Disposes this descriptor.
+ */
+ public void dispose() {
+ if (image != null) {
+ image.dispose();
+ image = null;
+ }
+ }
}
diff --git a/plugins/org.eclipse.eef.properties.ui.legacy/src/org/eclipse/eef/properties/ui/legacy/internal/extension/impl/LegacyPropertyTabRegistry.java b/plugins/org.eclipse.eef.properties.ui.legacy/src/org/eclipse/eef/properties/ui/legacy/internal/extension/impl/LegacyPropertyTabRegistry.java
index f98daef52..78f55707a 100644
--- a/plugins/org.eclipse.eef.properties.ui.legacy/src/org/eclipse/eef/properties/ui/legacy/internal/extension/impl/LegacyPropertyTabRegistry.java
+++ b/plugins/org.eclipse.eef.properties.ui.legacy/src/org/eclipse/eef/properties/ui/legacy/internal/extension/impl/LegacyPropertyTabRegistry.java
@@ -264,4 +264,15 @@ public class LegacyPropertyTabRegistry implements IItemRegistry {
public void clear() {
this.id2descriptors.clear();
}
+
+ /**
+ * Disposes this registry.
+ */
+ public void dispose() {
+ for (IItemDescriptor desc : id2descriptors.values()) {
+ if (desc instanceof LegacyPropertyTabItemDescriptor) {
+ ((LegacyPropertyTabItemDescriptor) desc).dispose();
+ }
+ }
+ }
}
diff --git a/plugins/org.eclipse.eef.properties.ui.legacy/src/org/eclipse/eef/properties/ui/legacy/internal/extension/impl/LegacyPropertyTabsRegistryEventListener.java b/plugins/org.eclipse.eef.properties.ui.legacy/src/org/eclipse/eef/properties/ui/legacy/internal/extension/impl/LegacyPropertyTabsRegistryEventListener.java
index 3bf427b5f..bb8d9b2a2 100644
--- a/plugins/org.eclipse.eef.properties.ui.legacy/src/org/eclipse/eef/properties/ui/legacy/internal/extension/impl/LegacyPropertyTabsRegistryEventListener.java
+++ b/plugins/org.eclipse.eef.properties.ui.legacy/src/org/eclipse/eef/properties/ui/legacy/internal/extension/impl/LegacyPropertyTabsRegistryEventListener.java
@@ -16,7 +16,7 @@ import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.eef.properties.ui.legacy.internal.EEFPropertiesUiLegacyPlugin;
import org.eclipse.eef.properties.ui.legacy.internal.Messages;
import org.eclipse.eef.properties.ui.legacy.internal.extension.AbstractRegistryEventListener;
-import org.eclipse.swt.graphics.Image;
+import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
/**
@@ -140,14 +140,13 @@ public class LegacyPropertyTabsRegistryEventListener extends AbstractRegistryEve
String indentedString = propertyTab.getAttribute(INDENTED_ATTR);
boolean indented = indentedString != null && "true".equals(indentedString); //$NON-NLS-1$
String imageString = propertyTab.getAttribute(IMAGE_ATTR);
- Image image = null;
+ ImageDescriptor imageDesc = null;
if (imageString != null) {
- image = AbstractUIPlugin.imageDescriptorFromPlugin(propertyTab.getDeclaringExtension().getNamespaceIdentifier(), imageString)
- .createImage();
+ imageDesc = AbstractUIPlugin.imageDescriptorFromPlugin(propertyTab.getDeclaringExtension().getNamespaceIdentifier(), imageString);
}
LegacyPropertyTabItemDescriptor legacyPropertyTab = new LegacyPropertyTabItemDescriptor(contributorId, label, category, afterTab, id,
- indented, image);
+ indented, imageDesc);
this.propertyTabRegistry.add(legacyPropertyTab);
}
}

Back to the top