From 4a8eacaa5922d8863d26117d8fc0e2aa2dc4fb28 Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Wed, 26 May 2004 14:22:38 +0000 Subject: [PATCH] PR 61965 From Thomas Fletcher: 2.0 mainline scalability patch to call dispose methods and remove listeners --- core/org.eclipse.cdt.ui/ChangeLog | 7 + .../cdt/internal/ui/CPluginImages.java | 16 +- .../ui/editor/CContentOutlinePage.java | 55 ++++--- .../cdt/internal/ui/editor/CEditor.java | 138 ++++++++++++------ .../ui/editor/CEditorActionContributor.java | 7 + .../ui/editor/CEditorErrorTickUpdater.java | 7 + .../ui/editor/MouseClickListener.java | 12 +- .../search/actions/SelectionSearchGroup.java | 19 +++ .../ui/actions/MemberFilterActionGroup.java | 4 + .../ui/actions/RefactoringActionGroup.java | 41 ++++-- 10 files changed, 221 insertions(+), 85 deletions(-) diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog index 90eaf757d6f..e0f8a10e299 100644 --- a/core/org.eclipse.cdt.ui/ChangeLog +++ b/core/org.eclipse.cdt.ui/ChangeLog @@ -1,3 +1,10 @@ +2004-05-26 Alain Magloire + + PR 61965 + From Thomas Fletcher: + 2.0 mainline scalability patch to + call dispose methods and remove listeners + 2004-05-21 Andrew Niefer Indexer Problem reporting (bug 43014, 62979) * plugin.xml diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java index 7f447cd0e04..10267b5aa77 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java @@ -282,10 +282,18 @@ public class CPluginImages { * Sets all available image descriptors for the given action. */ public static void setImageDescriptors(IAction action, String type, String relPath) { - relPath= relPath.substring(NAME_PREFIX_LENGTH); - action.setDisabledImageDescriptor(create(T + "d" + type, relPath)); //$NON-NLS-1$ - action.setHoverImageDescriptor(create(T + "c" + type, relPath)); //$NON-NLS-1$ - action.setImageDescriptor(create(T + "e" + type, relPath)); //$NON-NLS-1$ +//Use the managed version so that we ensure that there is no resource handle leaks +//Let the widget itself manage the disabled/hover attribution. This was a huge leak +// relPath= relPath.substring(NAME_PREFIX_LENGTH); +// action.setDisabledImageDescriptor(create(T + "d" + type, relPath)); //$NON-NLS-1$ +// action.setHoverImageDescriptor(create(T + "c" + type, relPath)); //$NON-NLS-1$ +// action.setImageDescriptor(create(T + "e" + type, relPath)); //$NON-NLS-1$ + + ImageDescriptor desc = getImageRegistry().getDescriptor(relPath); + if(desc == null) { + desc = createManaged(T + "e" + type, relPath); + } + action.setImageDescriptor(desc); } /** diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java index eca4a5da5a6..8a096a538af 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java @@ -137,9 +137,6 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS } fRefactoringActionGroup.fillContextMenu(menu); - - - } /** @@ -147,7 +144,6 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS */ public void createControl(Composite parent) { treeViewer = new ProblemTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); - treeViewer.addSelectionChangedListener(this); treeViewer.setContentProvider(new CElementContentProvider(true, true)); treeViewer.setLabelProvider(new StandardCElementLabelProvider()); @@ -166,30 +162,55 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS Control control= treeViewer.getControl(); Menu menu= manager.createContextMenu(control); control.setMenu(menu); - // register global actions IPageSite site= getSite(); site.registerContextMenu(fContextMenuId, manager, treeViewer); site.setSelectionProvider(treeViewer); + IActionBars bars= site.getActionBars(); bars.setGlobalActionHandler(ICEditorActionDefinitionIds.TOGGLE_PRESENTATION, fTogglePresentation); - - registerToolbarActions(); fSelectionSearchGroup = new SelectionSearchGroup(this); fRefactoringActionGroup = new RefactoringActionGroup(this, null); treeViewer.setInput(fInput); - } public void dispose() { CUIPlugin.getDefault().getProblemMarkerManager().removeListener(treeViewer); + + if (treeViewer != null) { + treeViewer.removeSelectionChangedListener(this); + } + + if (fTogglePresentation != null) { + fTogglePresentation.setEditor(null); + fTogglePresentation= null; + } + if (fMemberFilterActionGroup != null) { fMemberFilterActionGroup.dispose(); fMemberFilterActionGroup= null; - } + } + + if (fRefactoringActionGroup != null) { + fRefactoringActionGroup.dispose(); + fRefactoringActionGroup= null; + } + + if (fSelectionSearchGroup != null) { + fSelectionSearchGroup.dispose(); + fSelectionSearchGroup= null; + } + + if (selectionChangedListeners != null) { + selectionChangedListeners.clear(); + selectionChangedListeners= null; + } + + fInput= null; + super.dispose(); } @@ -201,6 +222,9 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS LexicalSortingAction action= new LexicalSortingAction(getTreeViewer()); toolBarManager.add(action); + + fMemberFilterActionGroup= new MemberFilterActionGroup(treeViewer, "COutlineViewer"); //$NON-NLS-1$ + fMemberFilterActionGroup.fillActionBars(actionBars); } /* (non-Javadoc) @@ -276,8 +300,8 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS if (treeViewer != null) treeViewer.setSelection(selection); } - /** + * Set the current input to the content provider. * @param unit */ public void setInput(ITranslationUnit unit) { @@ -288,16 +312,5 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS contentUpdated(); } - private void registerToolbarActions() { - - IToolBarManager toolBarManager= getSite().getActionBars().getToolBarManager(); - if (toolBarManager != null) { - //toolBarManager.add(new ClassOnlyAction()); - //toolBarManager.add(new LexicalSortingAction()); - - fMemberFilterActionGroup= new MemberFilterActionGroup(treeViewer, "COutlineViewer"); //$NON-NLS-1$ - fMemberFilterActionGroup.contributeToToolBar(toolBarManager); - } - } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java index 7f7556c360a..e29a92f35a7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java @@ -76,13 +76,14 @@ import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.actions.ActionGroup; import org.eclipse.ui.editors.text.EditorsUI; import org.eclipse.ui.editors.text.TextEditor; +import org.eclipse.ui.ide.IDE; import org.eclipse.ui.part.EditorActionBarContributor; import org.eclipse.ui.part.IShowInSource; import org.eclipse.ui.part.ShowInContext; +import org.eclipse.ui.texteditor.AbstractTextEditor; import org.eclipse.ui.texteditor.AnnotationPreference; import org.eclipse.ui.texteditor.ChainedPreferenceStore; import org.eclipse.ui.texteditor.ContentAssistAction; -import org.eclipse.ui.texteditor.DefaultRangeIndicator; import org.eclipse.ui.texteditor.IEditorStatusLine; import org.eclipse.ui.texteditor.ITextEditorActionConstants; import org.eclipse.ui.texteditor.MarkerAnnotation; @@ -103,12 +104,14 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS protected CContentOutlinePage fOutlinePage; /** Search actions **/ - private ActionGroup fSelectionSearchGroup; private ActionGroup fRefactoringActionGroup; + private ShowInCViewAction fShowInCViewAction; + /** Activity Listeners **/ protected ISelectionChangedListener fStatusLineClearer; - + protected ISelectionChangedListener fSelectionUpdateListener; + /** The property change listener */ private PropertyChangeListener fPropertyChangeListener = new PropertyChangeListener(); /** The mouse listener */ @@ -158,29 +161,30 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS */ public CEditor() { super(); + } + + /** + * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#initializeEditor() + */ + protected void initializeEditor() { + //@@@ We should be able to get this from our parent fAnnotationPreferences = new MarkerAnnotationPreferences(); + CTextTools textTools = CUIPlugin.getDefault().getTextTools(); setSourceViewerConfiguration(new CSourceViewerConfiguration(textTools, this)); setDocumentProvider(CUIPlugin.getDefault().getDocumentProvider()); - setRangeIndicator(new DefaultRangeIndicator()); - //setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore()); - + setEditorContextMenuId("#CEditorContext"); //$NON-NLS-1$ setRulerContextMenuId("#CEditorRulerContext"); //$NON-NLS-1$ setOutlinerContextMenuId("#CEditorOutlinerContext"); //$NON-NLS-1$ - fCEditorErrorTickUpdater = new CEditorErrorTickUpdater(this); - } - - /* - * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#initializeEditor() - */ - protected void initializeEditor() { IPreferenceStore[] stores = new IPreferenceStore[2]; stores[0] = CUIPlugin.getDefault().getPreferenceStore(); stores[1] = EditorsUI.getPreferenceStore(); IPreferenceStore store = new ChainedPreferenceStore(stores); setPreferenceStore(store); + + fCEditorErrorTickUpdater = new CEditorErrorTickUpdater(this); } /** @@ -188,7 +192,9 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS */ protected void doSetInput(IEditorInput input) throws CoreException { super.doSetInput(input); - fCEditorErrorTickUpdater.setAnnotationModel(getDocumentProvider().getAnnotationModel(input)); + if (fCEditorErrorTickUpdater != null) { + fCEditorErrorTickUpdater.setAnnotationModel(getDocumentProvider().getAnnotationModel(input)); + } setOutlinePageInput(fOutlinePage, input); } @@ -297,16 +303,6 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS } } - /** - * - */ - private void disableBrowserLikeLinks() { - if (fMouseListener != null) { - fMouseListener.uninstall(); - fMouseListener= null; - } - } - /** * @see ISelectionChangedListener#selectionChanged */ @@ -437,18 +433,60 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS if (fCEditorErrorTickUpdater != null) { fCEditorErrorTickUpdater.setAnnotationModel(null); + fCEditorErrorTickUpdater.dispose(); fCEditorErrorTickUpdater = null; } - if (fBracketMatcher != null) { - fBracketMatcher.dispose(); - fBracketMatcher = null; - } + if (fPropertyChangeListener != null) { Preferences preferences = CCorePlugin.getDefault().getPluginPreferences(); preferences.removePropertyChangeListener(fPropertyChangeListener); IPreferenceStore preferenceStore = getPreferenceStore(); preferenceStore.removePropertyChangeListener(fPropertyChangeListener); + fPropertyChangeListener = null; + + } + + if (fSelectionUpdateListener != null) { + getSelectionProvider().addSelectionChangedListener(fSelectionUpdateListener); + fSelectionUpdateListener = null; } + + if (fStatusLineClearer != null) { + ISelectionProvider provider = getSelectionProvider(); + provider.removeSelectionChangedListener(fStatusLineClearer); + fStatusLineClearer = null; + } + + if (fBracketMatcher != null) { + fBracketMatcher.dispose(); + fBracketMatcher = null; + } + + if (fOutlinePage != null) { + fOutlinePage.dispose(); + fOutlinePage = null; + } + + if (fShowInCViewAction != null) { + fShowInCViewAction.dispose(); + fShowInCViewAction = null; + } + + if (fRefactoringActionGroup != null) { + fRefactoringActionGroup.dispose(); + fRefactoringActionGroup = null; + } + + if (fSelectionSearchGroup != null) { + fSelectionSearchGroup.dispose(); + fSelectionSearchGroup = null; + } + + stopTabConversion(); + disableBrowserLikeLinks(); + + fAnnotationPreferences = null; + super.dispose(); } @@ -517,11 +555,12 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS action.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_DECL); setAction("OpenDeclarations", action); //$NON-NLS-1$ - action = new ShowInCViewAction(this); + fShowInCViewAction = new ShowInCViewAction(this); + action = fShowInCViewAction; action.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_CVIEW); setAction("ShowInCView", action); //$NON-NLS-1$ - //Selection Search group + //Assorted action groupings fSelectionSearchGroup = new SelectionSearchGroup(this); fRefactoringActionGroup = new RefactoringActionGroup(this, null); @@ -574,7 +613,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS */ public void createPartControl(Composite parent) { super.createPartControl(parent); - ISelectionChangedListener sListener = new ISelectionChangedListener() { + fSelectionUpdateListener = new ISelectionChangedListener() { private Runnable fRunnable = new Runnable() { public void run() { updateStatusField(CTextEditorActionConstants.STATUS_CURSOR_POS); @@ -589,7 +628,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS fDisplay.asyncExec(fRunnable); } }; - getSelectionProvider().addSelectionChangedListener(sListener); + getSelectionProvider().addSelectionChangedListener(fSelectionUpdateListener); if (isTabConversionEnabled()) startTabConversion(); @@ -660,8 +699,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS if (nextError != null) { - - gotoMarker(nextError); + IDE.gotoMarker(this, nextError); IWorkbenchPage page = getSite().getPage(); @@ -875,10 +913,12 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS IWorkingCopyManager mgr = CUIPlugin.getDefault().getWorkingCopyManager(); ITranslationUnit unit = mgr.getWorkingCopy(getEditorInput()); String fileType = (unit != null && unit.isCXXLanguage()) ? LANGUAGE_CPP : LANGUAGE_C; - - fAnnotationAccess = createAnnotationAccess(); - ISharedTextColors sharedColors = CUIPlugin.getDefault().getSharedTextColors(); + fAnnotationAccess = createAnnotationAccess(); + + //TODO: TF NOTE: This can be greatly cleaned up using the parent createOverviewRuler method + //It will also totally get rid of the need for the fAnnotationPreferences in this object + ISharedTextColors sharedColors = CUIPlugin.getDefault().getSharedTextColors(); fOverviewRuler = new OverviewRuler(fAnnotationAccess, VERTICAL_RULER_WIDTH, sharedColors); Iterator e = fAnnotationPreferences.getAnnotationPreferences().iterator(); while (e.hasNext()) { @@ -900,6 +940,8 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS configureSourceViewerDecorationSupport(fSourceViewerDecorationSupport); + //TODO: TF NOTE: Add the bracket matching back in here! + return sourceViewer; } @@ -956,9 +998,8 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS } - //Links /** - * Enables browser like links. + * Enables browser like links, requires disable to clean up */ private void enableBrowserLikeLinks() { if (fMouseListener == null) { @@ -968,20 +1009,31 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS } } + /** + * Disable browser like links, clean up resources + */ + private void disableBrowserLikeLinks() { + if (fMouseListener != null) { + fMouseListener.uninstall(); + fMouseListener= null; + } + } + /** - * @return + * Determine if the hyperlink capability is enabled + * @return boolean indicating if hyperlinking is enabled */ private boolean hyperLinkEnabled() { IPreferenceStore store= getPreferenceStore(); - boolean Value = store.getBoolean(HYPERLINK_ENABLED); - return Value; + return store.getBoolean(HYPERLINK_ENABLED); } /* (non-Javadoc) * @see org.eclipse.cdt.internal.ui.editor.IReconcilingParticipant#reconciled() */ public void reconciled(boolean somethingHasChanged) { - if(somethingHasChanged) + if(somethingHasChanged && fOutlinePage != null) { fOutlinePage.contentUpdated(); + } } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorActionContributor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorActionContributor.java index 1ff07468e61..c4665721984 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorActionContributor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorActionContributor.java @@ -210,4 +210,11 @@ public class CEditorActionContributor extends TextEditorActionContributor { super.contributeToStatusLine(statusLineManager); } + /* (non-Javadoc) + * @see org.eclipse.ui.IEditorActionBarContributor#dispose() + */ + public void dispose() { + setActiveEditor(null); + super.dispose(); + } } \ No newline at end of file diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorErrorTickUpdater.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorErrorTickUpdater.java index a45f8cb3ffa..e9a6389ce02 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorErrorTickUpdater.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorErrorTickUpdater.java @@ -88,6 +88,13 @@ public class CEditorErrorTickUpdater implements IAnnotationModelListener { } } + public void dispose() { + if (fLabelProvider != null) { + fLabelProvider.dispose(); + fLabelProvider= null; + } + fAnnotationModel= null; + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/MouseClickListener.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/MouseClickListener.java index 15ab2b8ba4f..760b7147881 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/MouseClickListener.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/MouseClickListener.java @@ -201,18 +201,18 @@ IPropertyChangeListener{ fCursor= null; } - ISourceViewer sourceViewer= fViewer; - if (sourceViewer == null) - return; - IPreferenceStore preferenceStore= fPrefStore; if (preferenceStore != null) preferenceStore.removePropertyChangeListener(this); - + + ISourceViewer sourceViewer= fViewer; + if (sourceViewer == null) + return; + StyledText text= sourceViewer.getTextWidget(); if (text == null || text.isDisposed()) return; - + text.removeKeyListener(this); text.removeMouseListener(this); text.removeMouseMoveListener(this); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionSearchGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionSearchGroup.java index 1aa8206feed..9a8cd4242aa 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionSearchGroup.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionSearchGroup.java @@ -90,4 +90,23 @@ public class SelectionSearchGroup extends ActionGroup { } return null; } + + /* (non-Javadoc) + * @see org.eclipse.ui.actions.ActionGroup#dispose() + */ + public void dispose() { + if (fDeclarationsSearchGroup != null) { + fDeclarationsSearchGroup.dispose(); + fDeclarationsSearchGroup= null; + } + + if (fRefSearchGroup != null) { + fRefSearchGroup.dispose(); + fRefSearchGroup= null; + } + + fEditor= null; + + super.dispose(); + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/MemberFilterActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/MemberFilterActionGroup.java index 03fea001f9f..d544c2d2a8d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/MemberFilterActionGroup.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/MemberFilterActionGroup.java @@ -260,6 +260,10 @@ public class MemberFilterActionGroup extends ActionGroup { * @see ActionGroup#dispose() */ public void dispose() { + fFilterActions= null; + fFilter= null; + fViewer= null; + super.dispose(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/RefactoringActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/RefactoringActionGroup.java index 0e38a7447d1..9dba5e25a69 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/RefactoringActionGroup.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/RefactoringActionGroup.java @@ -102,9 +102,9 @@ public class RefactoringActionGroup extends ActionGroup { private CEditor fEditor; private String fGroupName= IContextMenuConstants.GROUP_REORGANIZE; - private SelectionDispatchAction fRenameAction; - private SelectionDispatchAction fRedoAction; - private SelectionDispatchAction fUndoAction; + private RenameRefactoringAction fRenameAction; + private RedoRefactoringAction fRedoAction; + private UndoRefactoringAction fUndoAction; private List fEditorActions; private static class NoActionAvailable extends Action { @@ -148,8 +148,8 @@ public class RefactoringActionGroup extends ActionGroup { ISelectionProvider provider= editor.getSelectionProvider(); ISelection selection= provider.getSelection(); - fEditorActions= new ArrayList(); - + fEditorActions= new ArrayList(3); + fRenameAction= new RenameRefactoringAction(editor); fRenameAction.update(selection); editor.setAction("RenameElement", fRenameAction); //$NON-NLS-1$ @@ -164,7 +164,7 @@ public class RefactoringActionGroup extends ActionGroup { fRedoAction.update(selection); editor.setAction("RedoAction", fRedoAction); //$NON-NLS-1$ fEditorActions.add(fRedoAction); -} + } public RefactoringActionGroup(IWorkbenchSite site, String groupName) { fSite= site; @@ -212,15 +212,34 @@ public class RefactoringActionGroup extends ActionGroup { */ public void dispose() { ISelectionProvider provider= fSite.getSelectionProvider(); - disposeAction(fRenameAction, provider); - disposeAction(fUndoAction, provider); - disposeAction(fRedoAction, provider); + + if (fRenameAction != null) { + disposeAction(fRenameAction, provider); + fRenameAction= null; + } + + if (fUndoAction != null) { + disposeAction(fUndoAction, provider); + fUndoAction.dispose(); + fUndoAction= null; + } + + if (fRedoAction != null) { + disposeAction(fRedoAction, provider); + fRedoAction.dispose(); + fRedoAction= null; + } + + if (fEditorActions != null) { + fEditorActions.clear(); + fEditorActions= null; + } + super.dispose(); } private void disposeAction(ISelectionChangedListener action, ISelectionProvider provider) { - if (action != null) - provider.removeSelectionChangedListener(action); + provider.removeSelectionChangedListener(action); } private void addRefactorSubmenu(IMenuManager menu) {