Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2014-03-27 18:48:54 +0000
committerChristian W. Damus2014-03-27 18:49:10 +0000
commitaca683fb78056238b7a5e533f55abf8b2e6ba0aa (patch)
tree7a73777adc34e9390ce1936e4bfc310c66b5d956 /plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui
parentee4591bbe74a80517780f021db9e550da17fbe79 (diff)
downloadorg.eclipse.papyrus-aca683fb78056238b7a5e533f55abf8b2e6ba0aa.tar.gz
org.eclipse.papyrus-aca683fb78056238b7a5e533f55abf8b2e6ba0aa.tar.xz
org.eclipse.papyrus-aca683fb78056238b7a5e533f55abf8b2e6ba0aa.zip
410346: Sudden performance degradation e.g. of the Outline View update.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=410346 Fix proliferation of item-provider adapters on model elements due to CompositeAdapterFactories being repeatedly created but never disposed.
Diffstat (limited to 'plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui')
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ImageQuery.java40
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/LabelQuery.java28
2 files changed, 37 insertions, 31 deletions
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ImageQuery.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ImageQuery.java
index 232c67c5999..5c9a88c06d8 100644
--- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ImageQuery.java
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ImageQuery.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2011, 2012 Mia-Software.
+ * Copyright (c) 2011, 2014 Mia-Software, CEA, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -11,6 +11,7 @@
* Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
* Nicolas Bros (Mia-Software) - Bug 379683 - customizable Tree content provider
* Gregoire Dupe (Mia-Software) - Bug 424122 - [Table] Images, fonts and colors are not shared between the instances of table
+ * Christian W. Damus (CEA) - bug 410346
*/
package org.eclipse.papyrus.emf.facet.custom.ui.internal.query;
@@ -19,10 +20,8 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.ETypedElement;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
-import org.eclipse.emf.edit.provider.ComposedImage;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.Activator;
import org.eclipse.papyrus.emf.facet.custom.ui.internal.ImageProvider;
import org.eclipse.papyrus.emf.facet.custom.ui.internal.custompt.ImageWrapper;
import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
@@ -31,9 +30,6 @@ import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetAttribu
import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetReference;
import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2;
import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2;
-import org.eclipse.papyrus.emf.facet.util.swt.imageprovider.IImageProvider;
-import org.eclipse.papyrus.emf.facet.util.swt.imageprovider.IImageProviderFactory;
-import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IImage;
import org.eclipse.swt.graphics.Image;
@@ -61,21 +57,25 @@ public class ImageQuery implements IJavaQuery2<EObject, IImage> {
IImage result = null;
final ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory(
ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
- final IItemLabelProvider itemLabelProvider = (IItemLabelProvider) adapterFactory
- .adapt(source, IItemLabelProvider.class);
- if (itemLabelProvider != null) {
- Object imageObject = itemLabelProvider.getImage(source);
- Image image = ExtendedImageRegistry.getInstance().getImage(imageObject);
- result = new ImageWrapper(image);
-//// final ImageDescriptor imgDescriptor = ExtendedImageRegistry
-//// .getInstance().getImageDescriptor(source);
-// final IImageProvider imgProvider = IImageProviderFactory.DEFAULT
-// .createIImageProvider(Activator.getDefault());
-// if (imgDescriptor != null) {
-// final Image image = imgProvider.getImage(imgDescriptor);
-// result = new ImageWrapper(image);
-// }
+
+ try {
+ final IItemLabelProvider itemLabelProvider = (IItemLabelProvider)adapterFactory.adapt(source, IItemLabelProvider.class);
+ if(itemLabelProvider != null) {
+ Object imageObject = itemLabelProvider.getImage(source);
+ Image image = ExtendedImageRegistry.getInstance().getImage(imageObject);
+ result = new ImageWrapper(image);
+//// final ImageDescriptor imgDescriptor = ExtendedImageRegistry.getInstance().getImageDescriptor(source);
+// final IImageProvider imgProvider = IImageProviderFactory.DEFAULT.createIImageProvider(Activator.getDefault());
+// if(imgDescriptor != null) {
+// final Image image = imgProvider.getImage(imgDescriptor);
+// result = new ImageWrapper(image);
+// }
+ }
+ } finally {
+ // Dispose the adapter factory because it added an adapter that would leak, as it will never be reused
+ adapterFactory.dispose();
}
+
return result;
}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/LabelQuery.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/LabelQuery.java
index 0d0d0130c20..8e5e5b7d05a 100644
--- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/LabelQuery.java
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/LabelQuery.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2011 Mia-Software.
+ * Copyright (c) 2011, 2014 Mia-Software, CEA, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -12,6 +12,7 @@
* Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
* Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>)
* Nicolas Bros (Mia-Software) - Bug 379683 - customizable Tree content provider
+ * Christian W. Damus (CEA) - bug 410346
*/
package org.eclipse.papyrus.emf.facet.custom.ui.internal.query;
@@ -47,16 +48,21 @@ public class LabelQuery implements IJavaQuery2<EObject, String> {
if (sfParam == null) {
final ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory(
ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
- final IItemLabelProvider itemLabelProvider = (IItemLabelProvider) adapterFactory
- .adapt(source, IItemLabelProvider.class);
- // We don't want to use a ReflectiveItemProvider because it provides
- // a string prefixed with the eObject's meta-class name.
- if (itemLabelProvider instanceof ReflectiveItemProvider) {
- result = LabelQuery.getDefaultName(source);
- } else if (itemLabelProvider == null) {
- result = ModelUtils.getDefaultName(source);
- } else {
- result = itemLabelProvider.getText(source);
+
+ try {
+ final IItemLabelProvider itemLabelProvider = (IItemLabelProvider)adapterFactory.adapt(source, IItemLabelProvider.class);
+ // We don't want to use a ReflectiveItemProvider because it provides
+ // a string prefixed with the eObject's meta-class name.
+ if(itemLabelProvider instanceof ReflectiveItemProvider) {
+ result = LabelQuery.getDefaultName(source);
+ } else if(itemLabelProvider == null) {
+ result = ModelUtils.getDefaultName(source);
+ } else {
+ result = itemLabelProvider.getText(source);
+ }
+ } finally {
+ // Dispose the adapter factory because it added an adapter that would leak, as nobody else will ever use it
+ adapterFactory.dispose();
}
} else {
try {

Back to the top