Skip to content

Commit

Permalink
[176] Adapt SiriusDiagramActionBarContributor to avoid memory leak
Browse files Browse the repository at this point in the history
Create a specific ActionBarContributor for each specific implementation
of SiriusDiagramEditor to avoid a duplication of ActionRegistry: one for
"SiriusDiagramEditor.class" and one for real implementation
("DDiagramEditorImpl.class" or "EcoreEntitiesReadOnlyEditor.class").
Indeed, only one of the ActionRegistry is correctly cleaned at the
closing of the editor.

Bug: #176
  • Loading branch information
lredor committed Mar 15, 2024
1 parent 6376565 commit b26a875
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 3 deletions.
2 changes: 1 addition & 1 deletion plugins/org.eclipse.sirius.diagram.ui/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
default="true"
class="org.eclipse.sirius.diagram.ui.tools.internal.editor.DDiagramEditorImpl"
matchingStrategy="org.eclipse.sirius.diagram.ui.part.SiriusMatchingStrategy"
contributorClass="org.eclipse.sirius.diagram.ui.part.SiriusDiagramActionBarContributor">
contributorClass="org.eclipse.sirius.diagram.ui.part.DDiagramEditorActionBarContributor">
</editor>
</extension>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*******************************************************************************
* Copyright (c) 2023 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/
package org.eclipse.sirius.diagram.ui.part;

import org.eclipse.sirius.diagram.ui.tools.internal.editor.DDiagramEditorImpl;

/**
* Specific ActionBarContributor for {@link DDiagramEditorImpl} instance to avoid potential leaks on actions for action
* bar of this editor.
*
* @author Laurent Redor
*/
public class DDiagramEditorActionBarContributor extends SiriusDiagramActionBarContributor {
@Override
protected Class<?> getEditorClass() {
return DDiagramEditorImpl.class;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ Eclipse-LazyStart: true
Bundle-Activator: org.eclipse.sirius.ecore.design.service.EcoreSamplePlugin
Export-Package: org.eclipse.sirius.ecore.design.service;version="3.0.0",
org.eclipse.sirius.sample.ecore.design.action;version="3.0.0",
org.eclipse.sirius.sample.ecore.design.editor;version="3.0.0"
org.eclipse.sirius.sample.ecore.design.editor;version="3.0.0",
org.eclipse.sirius.sample.ecore.design.editor.ui.part;version="3.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-17
Bundle-ActivationPolicy: lazy
Import-Package: org.eclipse.sirius.ext.base;version="2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion plugins/org.eclipse.sirius.sample.ecore.design/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
point="org.eclipse.ui.editors">
<editor
class="org.eclipse.sirius.sample.ecore.design.editor.EcoreEntitiesReadOnlyEditor"
contributorClass="org.eclipse.sirius.diagram.ui.part.SiriusDiagramActionBarContributor"
contributorClass="org.eclipse.sirius.sample.ecore.design.editor.ui.part.EcoreEntitiesActionBarContributor"
default="false"
extensions="ecore"
icon="icons/full/obj16/EcoreModelFile.gif"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*******************************************************************************
* Copyright (c) 2023 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/
package org.eclipse.sirius.sample.ecore.design.editor.ui.part;

import org.eclipse.sirius.diagram.ui.part.SiriusDiagramActionBarContributor;
import org.eclipse.sirius.sample.ecore.design.editor.EcoreEntitiesReadOnlyEditor;

/**
* Specific ActionBarContributor for {@link EcoreEntitiesReadOnlyEditor} instance to avoid potential leaks on actions
* for action bar of this editor.
*
* @author Laurent Redor
*/
public class EcoreEntitiesActionBarContributor extends SiriusDiagramActionBarContributor {
@Override
protected Class<?> getEditorClass() {
return EcoreEntitiesReadOnlyEditor.class;
}
}

0 comments on commit b26a875

Please sign in to comment.