Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2435,7 +2435,11 @@ public void ensureCleanUpAddonCleansUp() {
partStackForEditor.getChildren().add(editor);
partStackForEditor.setSelectedElement(editor);

ContextInjectionFactory.make(CleanupAddon.class, appContext);
// Store the addon in the context so it isn't garbage collected before
// its event handlers fire. The DI framework holds injected objects
// only via WeakReference, so an addon discarded here can be collected
// before its asyncExec runs, silently invalidating the requestor.
appContext.set(CleanupAddon.class, ContextInjectionFactory.make(CleanupAddon.class, appContext));

contextRule.createAndRunWorkbench(window);

Expand All @@ -2445,8 +2449,6 @@ public void ensureCleanUpAddonCleansUp() {

assertTrue(partStackForPartBPartC.isToBeRendered(), " PartStack with children should be rendered");
partService.hidePart(partB);
// Drain pending events between hides so that the event queue is clean
// when the second hidePart queues CleanupAddon's asyncExec for visCount==0
contextRule.spinEventLoop();
partService.hidePart(partC);
contextRule.spinEventLoop();
Expand Down Expand Up @@ -2494,7 +2496,8 @@ public void testBug332463() {
partStackB.getChildren().add(partC);
partStackB.setSelectedElement(partC);

ContextInjectionFactory.make(CleanupAddon.class, appContext);
// See ensureCleanUpAddonCleansUp for why the addon is stored in the context.
appContext.set(CleanupAddon.class, ContextInjectionFactory.make(CleanupAddon.class, appContext));

contextRule.createAndRunWorkbench(window);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ private void prepareApplicationModel() {
appContext.set(MAddon.class, cleanupAddon);

ContextInjectionFactory.setDefault(appContext);
ContextInjectionFactory.make(CleanupAddon.class, appContext);
// Store the addon in the context so it isn't garbage collected before
// its event handlers fire. The DI framework holds injected objects
// only via WeakReference, so an addon discarded here can be collected
// before its asyncExec runs, silently invalidating the requestor.
appContext.set(CleanupAddon.class, ContextInjectionFactory.make(CleanupAddon.class, appContext));

appContext.set(IResourceUtilities.class, new ISWTResourceUtilities() {

Expand Down
Loading