Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 354685

Summary: [Compatibility] IWorkbenchPartReference does not initialize on legacy EditorParts
Product: [Eclipse Project] Platform Reporter: Thomas Kratz <eiswind>
Component: UIAssignee: Platform-UI-Inbox <Platform-UI-Inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: remy.suen
Version: 4.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Thomas Kratz CLA 2011-08-13 06:25:15 EDT
Build Identifier: e4.1 M7

I have a WorkbenchPartListener which is called on close of my editors. Inside the listener I have
private Object getEntity(IWorkbenchPartReference ref) {
		IWorkbenchPart part = ref.getPart(true);
		if (!(part instanceof IEditorPart)) {
			return null;
		}
		IEditorPart editor = (IEditorPart) part;

to get access to the actual editor part and its input. But the call to ref.getPart(true) returns null in my case. Sadly I do not correctly understand the inner workings of this method, legacypart of the reference is null in my case but size of children after the init is not 1.

Would be great if we could investigate this, as my database record stays locked until timeout as long as the close of my editors is not recognised.

Reproducible: Always
Comment 1 Thomas Kratz CLA 2011-08-13 06:27:33 EDT
PS if this should be going to "runtime" please change it, I'm not sure.
Comment 2 Remy Suen CLA 2011-08-13 07:16:57 EDT
(In reply to comment #0)
> Build Identifier: e4.1 M7
> 
> I have a WorkbenchPartListener which is called on close of my editors. Inside
> the listener I have
> private Object getEntity(IWorkbenchPartReference ref) {
>         IWorkbenchPart part = ref.getPart(true);
>         if (!(part instanceof IEditorPart)) {
>             return null;
>         }
>         IEditorPart editor = (IEditorPart) part;
> 
> to get access to the actual editor part and its input. But the call to
> ref.getPart(true) returns null in my case.

This sounds to me like the same problem as bug 342366.
http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?h=R4_development&id=faeb9c58f9da28ab87e2f96edb03dd1d41365553

(In reply to comment #1)
> PS if this should be going to "runtime" please change it, I'm not sure.

With 4.1 out the door, you can just open bugs against Platform/UI and then put the version as 4.1, Thomas.
Comment 3 Thomas Kratz CLA 2011-08-13 07:34:12 EDT
Thanks Remy, that solved my problem. 
I fail to update my target platform :) is always  trouble with my patches and getting the build to work again.