Community
Participate
Working Groups
Build Identifier: Build id: 20100617-1415 When ToolBar is disabled, use (couple of times) of setOrientation makes the images in ToolBar to disappear in original orientation. Let say we run in LTR GUI (ControlExamle - in org.eclipse.swt.examples.mirroringTest package.), if we disable the toolbar then click couple of times on the "set orientation SWT.LEFT_TO_RIGHT" the images begin to disappear (see steps to Reproduce). Reproducible: Always Steps to Reproduce: attachment 194265 [details] Steps to Reproduce: 1. Apply the attached patch on the "org.eclipse.swt.examples" project (project level). 2. Go to org.eclipse.swt.examples.mirroringTest package. 3. Run the ControlExamle. 4. Go to the "Toolbar" Tab. 5. In "Others..." group the "Enabled..." option should be unchecked. 6. In "Orientation..." group choose "set orientation SWT.LEFT_TO_RIGHT". resulrt - some of the icons disappeare. Notes: 1. if you'll keep toggle between "set orientation SWT.LEFT_TO_RIGHT" to " group choose "SWT.LEFT_TO_RIGHT" the icons eventually will all disapeare in the SWT.LEFT_TO_RIGHT view. 2. same happens (but oppositely) in the mirrored GUI you can use the ControlExamleRTL to reproduce.
Created attachment 194436 [details] picture of the problem.
This problem was spotted by Helena last week: https://bugs.eclipse.org/bugs/show_bug.cgi?id=341282#c13 Helena, do you have a fix ? Note that your code in original patch is also wrong. As long as we remove the image from one image list (by disposing it), and add to some other image list. The disabledImageList and the imageList will be out of sync. Using ImageList#indexOf/ImageList#put is not correct. You fix the case for toolbar that is changing, but is possible some other toolbar has some other image at the same index that you are forcing the new image with ImageList#put, thus breaking another user. Steps: Run control example Go to ToolBar tab change (dynamically) the orientation to RTL change back (dynamically) the orientation to LTR uncheck the enable button Go to CoolBar tab (the images in the toolbar inside of the coolbar are wrong).
Helena, RC1 is next week. It would be good if we could get a fix by Mon or Tue. Thank you.
Created attachment 195203 [details] patch - changes in ToolBar and ToolItem To TooItem added indexes to store indexes of image in ImageList-ltr and ImageList-rtl. Also added disabledImage2Rtl to store disabled image, that is used in disabledImageList-rtl. When the item should be released, and function releaseImages is called, the images are removed from ltr and rtl image lists.
The code is still wrong. Toolbars share image lists, but they never share the images in the image list. You can't use ImageList#indexOf basically. It is possible that someother ToolBar has the same image as the toolbar that is changing, but you can never use the same image index cause one toolbar can disabled and other enabled... Here is a test case, run it and press F1: public static void main(String[] args) { Display display= new Display(); Shell shell= new Shell(display); Image image0 = new Image (display, "build_exec.gif"); Image image1 = new Image (display, "debug_exc.gif"); final ToolBar bar = new ToolBar (shell, SWT.FLAT); ToolItem item0 = new ToolItem (bar, SWT.CHECK); item0.setText("1."); item0.setImage(image0); bar.setOrientation(SWT.RIGHT_TO_LEFT); bar.setOrientation(SWT.LEFT_TO_RIGHT); final ToolBar bar2 = new ToolBar (shell, SWT.FLAT | SWT.RIGHT_TO_LEFT ); ToolItem item1 = new ToolItem (bar2, SWT.CHECK); item1.setText("2."); item1.setImage(image0); bar2.setEnabled(false); display.addFilter(SWT.KeyDown, new Listener() { public void handleEvent(Event event) { bar.setOrientation(bar.getOrientation() == SWT.RIGHT_TO_LEFT ? SWT.LEFT_TO_RIGHT : SWT.RIGHT_TO_LEFT); bar2.redraw(); } }); shell.setLayout(new GridLayout()); shell.setSize(300, 300); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } ----
Helena, what about this ? I just wrote it up, can you break it ? does it leak or something ? pls help test. void updateOrientation () { super.updateOrientation (); if (imageList != null) { Point size = imageList.getImageSize (); ImageList newImageList = display.getImageListToolBar (style & SWT.RIGHT_TO_LEFT, size.x, size.y); ImageList newHotImageList = display.getImageListToolBarHot (style & SWT.RIGHT_TO_LEFT, size.x, size.y); ImageList newDisabledImageList = display.getImageListToolBarDisabled (style & SWT.RIGHT_TO_LEFT, size.x, size.y); TBBUTTONINFO info = new TBBUTTONINFO (); info.cbSize = TBBUTTONINFO.sizeof; info.dwMask = OS.TBIF_IMAGE; int count = (int)/*64*/OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0); for (int i=0; i<count; i++) { ToolItem item = items [i]; if ((item.getStyle() & SWT.SEPARATOR) != 0) continue; if (item.image == null) continue; OS.SendMessage (handle, OS.TB_GETBUTTONINFO, item.id, info); if (info.iImage != OS.I_IMAGENONE) { Image image = imageList.get(info.iImage); Image hot = hotImageList.get(info.iImage); Image disabled = disabledImageList.get(info.iImage); imageList.put(info.iImage, null); hotImageList.put(info.iImage, null); disabledImageList.put(info.iImage, null); info.iImage = newImageList.add(image); newHotImageList.add(hot); newDisabledImageList.add(disabled); OS.SendMessage (handle, OS.TB_SETBUTTONINFO, item.id, info); } } display.releaseToolImageList (imageList); display.releaseToolHotImageList (hotImageList); display.releaseToolDisabledImageList (disabledImageList); OS.SendMessage (handle, OS.TB_SETIMAGELIST, 0, newImageList.getHandle ()); OS.SendMessage (handle, OS.TB_SETHOTIMAGELIST, 0, newHotImageList.getHandle ()); OS.SendMessage (handle, OS.TB_SETDISABLEDIMAGELIST, 0, newDisabledImageList.getHandle ()); imageList = newImageList; hotImageList = newHotImageList; disabledImageList = newDisabledImageList; } }
(In reply to comment #6) > Helena, what about this ? > I just wrote it up, can you break it ? does it leak or something ? pls help > test. > I tested it. A part of enabled images disappeared, a part of disabled images are shown enabled, but if to add redraw() in the end of updateOrientation, all works fine.
(In reply to comment #7) > (In reply to comment #6) > > Helena, what about this ? > > I just wrote it up, can you break it ? does it leak or something ? pls help > > test. > > > I tested it. > A part of enabled images disappeared, a part of disabled images are shown > enabled, but if to add redraw() in the end of updateOrientation, all works > fine. not sure I understood, can you provide steps (or a testcase) so I can reproduce the problem here ?
(In reply to comment #8) > not sure I understood, can you provide steps (or a testcase) so I can reproduce > the problem here ? Run ControlExample. Click on F1 2 tmes. Several images disappered. Minimize window, maximize. All images restored. Disable toolbar. F1. Several images now enabled. Minimize, maximize the window. All images disabled.
(In reply to comment #9) > (In reply to comment #8) > > not sure I understood, can you provide steps (or a testcase) so I can reproduce > > the problem here ? > Run ControlExample. Click on F1 2 tmes. Several images disappered. Minimize > window, maximize. All images restored. > Disable toolbar. F1. Several images now enabled. Minimize, maximize the window. > All images disabled. with my patch ? it works fine for me on windows 7 what are you testing ? xp ?
(In reply to comment #10) > with my patch ? it works fine for me on windows 7 > what are you testing ? xp ? Your patch, XP
(In reply to comment #11) > (In reply to comment #10) > > with my patch ? it works fine for me on windows 7 > > what are you testing ? xp ? > Your patch, > XP and adding OS.InvalidateRect (handle, null, true); to end of the method solves the problem ?
(In reply to comment #12) > and adding OS.InvalidateRect (handle, null, true); to end of the method solves > the problem ? yes
Created attachment 195397 [details] patch
Silenio, I rewrote updateOrientation() for Toolbar. -We tested the code on Windows 7 and XP -This only affects people calling the new API -I tested with Sleak
fixed in head