Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2014-03-26 16:53:14 +0000
committerChristian W. Damus2014-03-26 16:54:12 +0000
commitdf246c52d356a904bbaa011d2fc8614f1740fb26 (patch)
tree1535fb6382592a688a633b88432eb4a348dc8b26 /plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src
parentf12302507980877dabb32d3fb9dbfd7e8713a49c (diff)
downloadorg.eclipse.papyrus-df246c52d356a904bbaa011d2fc8614f1740fb26.tar.gz
org.eclipse.papyrus-df246c52d356a904bbaa011d2fc8614f1740fb26.tar.xz
org.eclipse.papyrus-df246c52d356a904bbaa011d2fc8614f1740fb26.zip
392301: Colors are leaked
https://bugs.eclipse.org/bugs/show_bug.cgi?id=392301 Fix leaks of images in the Papyrus multi-editor tabs.
Diffstat (limited to 'plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src')
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IPageModel.java22
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ErrorComponentPart.java8
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/TabFolderPart.java19
3 files changed, 43 insertions, 6 deletions
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IPageModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IPageModel.java
index 9076761efb6..a8b1c6aeb42 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IPageModel.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IPageModel.java
@@ -1,6 +1,17 @@
-/**
- *
- */
+/*****************************************************************************
+ * Copyright (c) 2011, 2014 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *
+ * CEA LIST - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 392301
+ *
+ *****************************************************************************/
package org.eclipse.papyrus.infra.core.sasheditor.contentprovider;
import org.eclipse.swt.graphics.Image;
@@ -38,5 +49,10 @@ public abstract interface IPageModel {
* @return
*/
public Object getRawModel();
+
+ /**
+ * Dispose any resources that I have allocated, such as (for example), an {@linkplain #getTabIcon() image}.
+ */
+ public void dispose();
}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ErrorComponentPart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ErrorComponentPart.java
index 6f912300cf5..05db1f3c22f 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ErrorComponentPart.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ErrorComponentPart.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 392301
+ *
*****************************************************************************/
package org.eclipse.papyrus.infra.core.sasheditor.internal;
@@ -39,6 +41,10 @@ public class ErrorComponentPart extends ComponentPart {
private static IComponentModel createErrorComponentPartModel() {
IComponentModel componentModel = new IComponentModel() {
+ public void dispose() {
+ // Pass. The tab icon is a workbench-shared icon
+ }
+
public String getTabTitle() {
return "Invalid tab";
}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/TabFolderPart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/TabFolderPart.java
index eda41017c48..9b1a97f0625 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/TabFolderPart.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/TabFolderPart.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2008 CEA LIST.
+ * Copyright (c) 2008, 2014 CEA LIST and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,6 +9,7 @@
*
* Contributors:
* Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 392301
*
*****************************************************************************/
package org.eclipse.papyrus.infra.core.sasheditor.internal;
@@ -28,6 +29,8 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabFolderEvent;
import org.eclipse.swt.custom.CTabItem;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.MenuDetectEvent;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseTrackListener;
@@ -1041,7 +1044,7 @@ public class TabFolderPart extends AbstractTabFolderPart implements IFolder {
private PagePart createChildPart(Object newModel) {
// Create the child PartModel. Delegate creation to this part PartModel.
- IPageModel partModel = getPartModel().createChildSashModel(newModel);
+ final IPageModel partModel = getPartModel().createChildSashModel(newModel);
if(partModel != null) {
// Delegate part creation to the container. This allow the container to provide appropriate
@@ -1053,6 +1056,18 @@ public class TabFolderPart extends AbstractTabFolderPart implements IFolder {
newPart.createPartControl(getControl());
getSashWindowContainer().getLifeCycleEventProvider().firePageOpenedEvent(newPart);
+ if(newPart.getControl() != null) {
+ newPart.getControl().addDisposeListener(new DisposeListener() {
+
+ public void widgetDisposed(DisposeEvent e) {
+ // Dispose the model that generated the part
+ partModel.dispose();
+ }
+ });
+ } else {
+ // No part control? Dispose the model, now
+ partModel.dispose();
+ }
return newPart;
}

Back to the top