Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 376442 - [Compatibility] View toolbar does not redraw properly when new buttons appear/disappear
Summary: [Compatibility] View toolbar does not redraw properly when new buttons appear...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.2   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.2 M7   Edit
Assignee: Michael Rennie CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 331444
  Show dependency tree
 
Reported: 2012-04-10 16:41 EDT by Marc Khouzam CLA
Modified: 2012-04-30 22:36 EDT (History)
4 users (show)

See Also:


Attachments
Screenshot showing the poor redrawing (58.92 KB, image/png)
2012-04-10 16:41 EDT, Marc Khouzam CLA
no flags Details
Example to reproduce the problem. (15.95 KB, patch)
2012-04-17 19:10 EDT, Pawel Piech CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Khouzam CLA 2012-04-10 16:41:55 EDT
Created attachment 213825 [details]
Screenshot showing the poor redrawing

CDT provides a feature to allow to do reverse debugging (step backwards).

When reverse debugging is possible, CDT makes visible 4 new buttons on the
debug toolbar: "reverse step into", "reverse step over", "reverse resume", and
"uncall" (reverse step return).

This small howto shows screenshots of the buttons and how to enable them:
http://wiki.eclipse.org/CDT/User/FAQ#How_do_I_do_Reverse_Debugging.3F

The problem is that when the 4 new buttons become visible (or invisible), the view toolbar does not redraw properly to make room (or remove room) for the new buttons.

After resizing the view, the toolbar is redrawn nicely.

Attached is a screenshot showing:
1- the normal toolbar
2- the proper toolbar with the extra buttons after a resize of the view
3- the error where buttons were hidden and the view toolbar has extra space
4- the error where buttons were made visible and the view is truncating buttons

If I can help get more information, please let me know.
Comment 1 Paul Webster CLA 2012-04-10 19:20:15 EDT
OK, we expect org.eclipse.ui.internal.e4.compatibility.ActionBars.updateActionBars() to re-layout the CTabFolder and all of its children, but we might not be picking the correct composite.

Marc, which build did you use?

PW
Comment 2 Paul Webster CLA 2012-04-11 07:36:25 EDT
Eric, when org.eclipse.ui.internal.e4.compatibility.ActionBars.updateActionBars() is called we need to re-layout the CTabFolder for that part stack.  Right now it's just guessing at a parent, we probably shouldn't do that.

Any suggestions?

PW
Comment 3 Marc Khouzam CLA 2012-04-11 08:57:35 EDT
(In reply to comment #1)

> Marc, which build did you use?

Sorry, I should have mentioned that.  I'm using the latest I-build: I20120321
Comment 4 Marc Khouzam CLA 2012-04-11 10:11:44 EDT
Little detail that may or may not be useful.  If I select anything outside the debug view, the toolbar redraws properly; re-sizing the debug view or selecting something outside of it fixes the problem.
Comment 5 Eric Moffatt CLA 2012-04-11 11:26:21 EDT
Paul, the MPartStack's widget is the CTF, no guessing required. If you have already changed the size of the toolbar (i.e. through 'pack') then a 'layout(true, true)' on the CTF should do the trick.

If not get back to me and I'll get together with Bogdan...
Comment 6 Eric Moffatt CLA 2012-04-11 11:28:27 EDT
Changing to M7 as this should be a quick code fix...

Also, we could add a size change listener to the TB so that when the 'pack' changes its size we can force the layout.

Is there a way for me to see this without having to install CDT ??
Comment 7 Marc Khouzam CLA 2012-04-11 13:21:16 EDT
(In reply to comment #6)

> Is there a way for me to see this without having to install CDT ??

I tried to find another action set that enables buttons on a view toolbar but I couldn't quite find one.  The only ones that I know of are in CDT (then again, I only really know CDT...).
Comment 8 Paul Webster CLA 2012-04-11 20:43:08 EDT
Eric, to reproduce we just have to have a view that when asked directly adds or removes IContributionItems from getViewSite().getActionBars().getToolBarManager() and then calls getViewSite().getActionBars().updateActionBars().

I should be able to give you a reproducible test case tomorrow.

PW
Comment 9 Pawel Piech CLA 2012-04-12 00:07:41 EDT
(In reply to comment #8)
The debug view does this now: open the view menu and select "Show Debug Toolbar".  However this works as expected.

The action that marc is referring to doesn't call update action bars directly.  Instead it calls the IEvaluationService.requestEvaluation() on a property that it modified.  I'll see if I can get the handler to call updateActionBars() rectly.
Comment 10 Pawel Piech CLA 2012-04-12 00:42:21 EDT
It seems that it won't be enough to try to update action bars just for the location where the handler was called.  I can make a simplified example of what the CDT reverse debugging commands are doing using the PDA debugger example in platform, if that will make it simpler to debug.
Comment 11 Paul Webster CLA 2012-04-12 06:15:22 EDT
(In reply to comment #9)
> The action that marc is referring to doesn't call update action bars directly. 
> Instead it calls the IEvaluationService.requestEvaluation() on a property that
> it modified.  I'll see if I can get the handler to call updateActionBars()
> rectly.

Oh, are these contributed through org.eclipse.ui.menus with a core expression?  Then we should be handling that ourselves (just in a slightly different location).

PW
Comment 12 Marc Khouzam CLA 2012-04-12 09:28:01 EDT
(In reply to comment #11)
> (In reply to comment #9)
> > The action that marc is referring to doesn't call update action bars directly. 
> > Instead it calls the IEvaluationService.requestEvaluation() on a property that
> > it modified.  I'll see if I can get the handler to call updateActionBars()
> > rectly.
> 
> Oh, are these contributed through org.eclipse.ui.menus with a core expression? 

Pretty much, but with a little more steps in between using definitions.  Here is the xml, if it helps.

Definition of the reverse-resume button:

 <extension
       point="org.eclipse.ui.menus">
      <menuContribution
            locationURI="toolbar:org.eclipse.debug.ui.DebugView?after=threadGroup">
         <command
               commandId="org.eclipse.cdt.debug.ui.command.reverseResume"
               icon="icons/obj16/reverse_resume.gif"
               label="%ReverseResume.label"
               style="push">
            <visibleWhen
                  checkEnabled="false">
               <reference  
        definitionId="org.eclipse.cdt.debug.ui.testIsReverseDebuggingEnabled">
               </reference>
            </visibleWhen>
         </command>
      </menuContribution>

which uses the following definition:

            <definition
                  id="org.eclipse.cdt.debug.ui.testIsReverseDebuggingEnabled">
               <and>
                  <reference
      definitionId="org.eclipse.cdt.debug.ui.testIsReverseDebuggingActionSetActive">
                  </reference>
                     <with
                           variable="debugContext">
                        <iterate
                              ifEmpty="false"
                              operator="and">
                           <test
              property="org.eclipse.cdt.debug.ui.isReverseDebuggingEnabled">
                           </test>
                        </iterate>
                     </with>
               </and>
            </definition>

which uses the following property:

   <extension
         point="org.eclipse.core.expressions.propertyTesters">
      <propertyTester
            class="org.eclipse.cdt.dsf.gdb.internal.ui.actions.ReverseDebuggingPropertyTester"
            id="org.eclipse.cdt.dsf.gdb.ui.selectionReverseDebuggingTester"
            namespace="org.eclipse.cdt.debug.ui"
            properties="isReverseDebuggingEnabled"
            type="org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext">
      </propertyTester>

So, in the java code, we sometimes need to refresh this isReverseDebuggingEnabled property and we use:

IEvaluationService.requestEvaluation("org.eclipse.cdt.debug.ui.isReverseDebuggingEnabled")
Comment 13 Michael Rennie CLA 2012-04-17 08:58:54 EDT
(In reply to comment #10)
> It seems that it won't be enough to try to update action bars just for the
> location where the handler was called.  I can make a simplified example of what
> the CDT reverse debugging commands are doing using the PDA debugger example in
> platform, if that will make it simpler to debug.

Yes, that would make it much easier to debug, thanks Pawel.

If I had to guess, I would say the new logic in EvaluationReference#evaluate(..) might be causing problems. I'll work with Pawel to get a simple example of the problem and dig deeper.
Comment 14 Pawel Piech CLA 2012-04-17 19:10:51 EDT
Created attachment 214154 [details]
Example to reproduce the problem.

Well well, I refactored the CDT reverse toggle enablement logic as to do something equivalent with the platform PDA example: instead of toggling reverse debugging actions, this one toggles visibility of the restart action.

The only problem is that my patch works!  The action appears/disappears as expected.  Not sure if this is good news or bad news, but as an example of the bug, it's a failure :-(
Comment 15 Marc Khouzam CLA 2012-04-18 10:47:32 EDT
(In reply to comment #14)
> Created attachment 214154 [details]
> Example to reproduce the problem.

Thanks!

> The only problem is that my patch works!  The action appears/disappears as
> expected.  Not sure if this is good news or bad news, but as an example of the
> bug, it's a failure :-(

Good news is that for me, when I try your example, things break as they do for CDT.  I start the PDA debugger then I press the new "enable restart" button and nothing happens, then I click somewhere else, and the restart button appears.

I'm using I20120411-2034 and the latest (just did a fetch) plaform debug code from git.

Pawel, do you see the problem with CDT reverse toggle or is it something with my own environment?
Comment 16 Pawel Piech CLA 2012-04-18 11:05:44 EDT
(In reply to comment #15)
> Pawel, do you see the problem with CDT reverse toggle or is it something with
> my own environment?

Yes, I see the problem with reverse debugging buttons, so I was rather surprised that the example didn't work.  I also sometimes see painting artefacts where the toolbar icons paint over the menu triangle, but not with the example.
Comment 17 Marc Khouzam CLA 2012-04-18 11:15:00 EDT
(In reply to comment #16)
> (In reply to comment #15)
> > Pawel, do you see the problem with CDT reverse toggle or is it something with
> > my own environment?
> 
> Yes, I see the problem with reverse debugging buttons, so I was rather
> surprised that the example didn't work.  I also sometimes see painting
> artefacts where the toolbar icons paint over the menu triangle, but not with
> the example.

I see the triangle being painted over with the example and I see the extra empty space when the button is removed with the example.  

BTW, I'm on Ubuntu 10.4 with GTK 2.20.1.  
I also see other redrawing problems that I reported in Bug 376633.
Comment 18 Marc Khouzam CLA 2012-04-29 22:17:34 EDT
Good news, the situation is much better when I use I20120429-1800.

In truth, everything seems ok except a little flicker when the redrawing is done.  During that flicker, I can see the view menu triangle appear for a split second in the wrong place, and then everything is ok.

I'm not sure if you want to keep the bug open for that, but from a CDT point-of-view, the problem is fixed.

Thanks!
Comment 19 Michael Rennie CLA 2012-04-30 22:36:10 EDT
(In reply to comment #18)
> Good news, the situation is much better when I use I20120429-1800.
> 
> In truth, everything seems ok except a little flicker when the redrawing is
> done.  During that flicker, I can see the view menu triangle appear for a split
> second in the wrong place, and then everything is ok.
> 
> I'm not sure if you want to keep the bug open for that, but from a CDT
> point-of-view, the problem is fixed.
> 
> Thanks!

Thanks for reporting back Marc, I will mark this bug fixed. The toolbar flicker you describe sounds a lot like bug 364975.