This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 399401 - Toolbars render in wrong location when perspective added to a perspective-less workbench
Summary: Toolbars render in wrong location when perspective added to a perspective-les...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.3   Edit
Hardware: PC Android
: P3 normal with 2 votes (vote)
Target Milestone: 4.4 M2   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 394812 407455 414929 (view as bug list)
Depends on:
Blocks: 415096
  Show dependency tree
 
Reported: 2013-01-29 11:24 EST by Paul Elder CLA
Modified: 2013-09-17 05:22 EDT (History)
8 users (show)

See Also:
krzysztof.daniel: review? (emoffatt)


Attachments
screenshot (31.89 KB, image/png)
2013-05-28 05:13 EDT, Axel Mueller CLA
no flags Details
Naive patch (1.28 KB, patch)
2013-06-18 06:02 EDT, Krzysztof Daniel CLA
no flags Details | Diff
mylyn/context/zip (36.94 KB, application/octet-stream)
2013-06-18 06:03 EDT, Krzysztof Daniel CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Elder CLA 2013-01-29 11:24:31 EST
Seen while verifying bug 387606:

Steps to reproduce:
1) Start Eclipse.
2) Close all perspectives
3) Restart Eclipse.
4) Open the default perspective (e.g. Java Perspective)

The resulting layout of toolbars is unpredictable. Sometimes they layout after the perspective chooser, sometimes not. Sometimes the order differs from the correct order.

Restarting Eclipse a second time renders the toolbars in the correct location, as does opening another workbench window.

Reproduced on Windows (32-bit & 64 bit), and on Mac (64-bit) in 4.3-I20130128-2000.
Comment 1 Patrick Chuong CLA 2013-03-01 10:42:14 EST
I see similar issue by opening a new perspective, i.e from Java to Debug. As long as the workbench window is small enough, you see the toolbar items are added after the perspective chooser. I am using 4.3M5, on Windows7.
Comment 2 Eric Moffatt CLA 2013-03-01 14:32:43 EST
Patrick, could you attach a screen shot of the issue you are seeing ? I've seen Paul's issue but I'm unsure that what you're seeing is the same thing...

My suspicion here is that the 'fixZOrder' code isn't triggered during the rendering of the MToolbars, causing a mismatch between the SWT order and the model's...
Comment 3 Michael Rennie CLA 2013-05-08 15:40:38 EDT
*** Bug 407455 has been marked as a duplicate of this bug. ***
Comment 4 Axel Mueller CLA 2013-05-28 05:13:09 EDT
Created attachment 231604 [details]
screenshot

Problem persists in I20130516-2200
Not all toolbars are affected.
Comment 5 Axel Mueller CLA 2013-06-11 09:00:21 EDT
(In reply to comment #4)
I was able to isolate the problem. It is related to the global debug toolbar. When the Debug perspective is opened and I shutdown and restart Eclipse the global debug toolbar (and some other toolbars) appear right of the perspective chooser. If I switch then the perspective the global debug toolbar is still visible (although it should only be visible in the Debug perspective!). When I now shutdown and restart Eclipse (w/o doing anything else) the toolbars are located all correctly and the global debug toolbar only appears in the Debug perspective.
Comment 6 Eric Moffatt CLA 2013-06-17 10:22:43 EDT
This is really annoying, I'll mark it for release in the first service pack...

The problem is most likely that the PartRenderingEnging is not handling toolbars in its 'fixZOrder' code. This code is supposed to ensure that newly rendered elements (i.e. a toolbar just appearing for the first time) are properly placed in the containing composite's collection of 'child' controls...
Comment 7 Krzysztof Daniel CLA 2013-06-18 06:02:55 EDT
Created attachment 232490 [details]
Naive patch

I've noticed that when Toolbars/Trimbars hit the fixZOrder ordering loop they had no widget (kit.getWidget() returned null), so I've relaxed one if condition, which in effect restarts the ordering prevCtrl each time a null widget is found.  It works because we are not stuck with prevCtrl (which could be wrong if kid.getWidget returns null) and we use moveAbove rather than moveBelow(invalid reference).

I'd really appreciate a comment, as I'm new to this part of Eclipse.
Comment 8 Krzysztof Daniel CLA 2013-06-18 06:03:00 EDT
Created attachment 232491 [details]
mylyn/context/zip
Comment 9 Eric Moffatt CLA 2013-06-18 10:56:06 EDT
Thanks Krzysztof, I'll take a look at this once Kepler goes out and we're back to development mode.
Comment 10 Krzysztof Daniel CLA 2013-07-15 06:02:14 EDT
Eric,
any chance for a review?
Comment 11 Eric Moffatt CLA 2013-07-15 16:27:16 EDT
Krzysztof, this fix doesn't work for me. Here's how I'm testing...

1) Start Fresh, close Welcome and then the Java Perspective
2) Restart
3) Open the *Debug* perspective (I think that the problem occurs now only if there are new toolbars being added to the model so it's necessary to open a perspective that's never been opened yet...at least if I re-open the perspective I closed before the restart it doesn't exhibit the issue for me).

With your proposed patch I still see TB's appear after the perspective switcher...

Also, by inspection the fix won't work; the goal is to ensure that the SWT Z-order matches the order of the entries in the model. It's quite possible that there may be rendered toolbars (i.e. widget is non-null) followed by elements whose TBR is false (i.e. widget is null). In this case your patch would incorrectly reset 'prevCtrl' to null meaning that the element would be moved to the *beginning* of the SWT z-order.

I've just tracked the z-order we set for the 'launchActionSet' toolbar (which is the one mis-placed after the open and it *seems* to be being placed ocrrectly. I'm starting to wonder if I'm mis-placing the MToolControls defining the search and perspective switchers...
Comment 12 Krzysztof Daniel CLA 2013-07-29 14:59:09 EDT
Eric,

Ok, I spent some time investigating this issue and it is not related to debug toolbar. Static contributions are wrong, too, if only perspective is closed and reopened.
This symptom is partially explained by the fact that quick access and perspective chooser are created programatically at application workbench window creation.
If the model is right, then the problem would be model rendering - note that items in the debug toolbar also change their positions - so it is quite possibly that there is a for(Object o : list) used where it should not be.

Where should I look further?
Comment 13 Krzysztof Daniel CLA 2013-07-31 10:31:53 EDT
Now things got weird: I got debug toolbar before the quick access, and launch menu and java search after perspective chooser. It looks like a race on windows initialization.

Where are MToolControls put for search and perspective switchers? I'd like to check that place, too.
Comment 14 Paul Webster CLA 2013-07-31 11:17:32 EDT
(In reply to comment #13)
> 
> Where are MToolControls put for search and perspective switchers? I'd like
> to check that place, too.

They're created in org.eclipse.ui.internal.WorkbenchWindow.populateTopTrimContributions()

PW
Comment 15 Michael Rennie CLA 2013-08-07 12:02:09 EDT
*** Bug 394812 has been marked as a duplicate of this bug. ***
Comment 16 Krzysztof Daniel CLA 2013-08-13 01:37:59 EDT
*** Bug 414929 has been marked as a duplicate of this bug. ***
Comment 17 Evgeniy Gil CLA 2013-08-13 02:17:32 EDT
How i can see in Debug the problem with control positioning caused by next situation:
If toolbar that has the previous position from anchor (parameter of "after=" in locationURI) is invisible the fixZOrder method try to position new toolbar after it by Control.moveAbove method but cannot do it because this (invisible) control is not presented in main toolbar composite. Thus the new toolbar became the last positioned (after PerspectiveSwitcher)
Comment 18 Evgeniy Gil CLA 2013-08-13 02:20:18 EDT
after the fix that described in Bug 414929 the problem disappears
Comment 19 Krzysztof Daniel CLA 2013-08-13 02:24:16 EDT
Patch https://git.eclipse.org/r/15401 based on bug 414929 comment 1.
Comment 20 Krzysztof Daniel CLA 2013-08-13 02:26:01 EDT
Evgeniy, it would be good if you had signed CLA and created gerrit account. I'd ammend then the patch to list you as an author of the patch.
Comment 21 Evgeniy Gil CLA 2013-08-13 03:54:52 EDT
Krzyzstof, I did it just now
Comment 22 Krzysztof Daniel CLA 2013-08-13 04:19:50 EDT
(In reply to comment #21)
> Krzyzstof, I did it just now
Still no gerrit user
Comment 23 Evgeniy Gil CLA 2013-08-13 05:03:19 EDT
What should I do for it?
Comment 24 Krzysztof Daniel CLA 2013-08-13 05:10:37 EDT
(In reply to comment #23)
My bad :-). Here is the properly attributed patch https://git.eclipse.org/r/#/c/15401/

Eric,
I can't reproduce the bug with the patch applied, and the patch itself makes a lot of sense. Could you double-check it?
Comment 25 Eric Moffatt CLA 2013-08-14 13:42:01 EDT
Sweet ! This has really been bugging me, thanks a lot !

Committed (to master, I've changed the target milestone to match)

http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=a4a242259ce53cceb328b4715abd73da23550ce6

Works like a charm :)
Comment 26 Daniel Rolka CLA 2013-09-17 05:22:42 EDT
Verified in the build: I20130916-2330