diff options
author | Carolyn MacLeod | 2012-06-25 18:59:07 +0000 |
---|---|---|
committer | Bogdan Gheorghe | 2012-11-21 16:29:21 +0000 |
commit | 89fb38b5b1a97f9b2fc1fb11e0e0cdf75401ef8d (patch) | |
tree | 9be6bdd66a9eb97c07def905965fada6039f5b7c | |
parent | 9efef2504d71a1f3dabca0ee9c4c8c10c8b77046 (diff) | |
download | eclipse.platform.swt-89fb38b5b1a97f9b2fc1fb11e0e0cdf75401ef8d.tar.gz eclipse.platform.swt-89fb38b5b1a97f9b2fc1fb11e0e0cdf75401ef8d.tar.xz eclipse.platform.swt-89fb38b5b1a97f9b2fc1fb11e0e0cdf75401ef8d.zip |
Bug 339344 - CTabFolder with a disposed top right control cannot be
rendered
Conflicts:
bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java
2 files changed, 35 insertions, 31 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java index 52c2d8bf2d..b7306d1588 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java @@ -449,7 +449,7 @@ Rectangle[] computeControlBounds (Point size, boolean[][] position) { int rightWidth = 0; int allWidth = 0; for (int i = 0; i < controls.length; i++) { - Point ctrlSize = tabControlSize[i] = controls[i].getVisible() ? controls[i].computeSize(SWT.DEFAULT, SWT.DEFAULT) : new Point(0,0); + Point ctrlSize = tabControlSize[i] = !controls[i].isDisposed() && controls[i].getVisible() ? controls[i].computeSize(SWT.DEFAULT, SWT.DEFAULT) : new Point(0,0); int alignment = controlAlignments[i]; if ((alignment & SWT.LEAD) != 0) { rects[i].width = ctrlSize.x; @@ -578,7 +578,7 @@ Rectangle[] computeControlBounds (Point size, boolean[][] position) { //Relayout this control in the next line i--; } else { - ctrlSize = controls[i].computeSize(bodyWidth, SWT.DEFAULT); + ctrlSize = controls[i].isDisposed() ? new Point(0,0) : controls[i].computeSize(bodyWidth, SWT.DEFAULT); rects[i].width = bodyWidth; rects[i].y = y; rects[i].height = ctrlSize.y; @@ -880,7 +880,7 @@ int getLeftItemEdge (GC gc, int part){ int x = -trim.x; int width = 0; for (int i = 0; i < controls.length; i++) { - if ((controlAlignments[i] & SWT.LEAD) != 0 && controls[i].getVisible()) { + if ((controlAlignments[i] & SWT.LEAD) != 0 && !controls[i].isDisposed() && controls[i].getVisible()) { width += controls[i].computeSize(SWT.DEFAULT, SWT.DEFAULT).x; } } @@ -1056,7 +1056,7 @@ int getRightItemEdge (GC gc){ int width = 0; for (int i = 0; i < controls.length; i++) { int align = controlAlignments[i]; - if ((align & SWT.WRAP) == 0 && (align & SWT.LEAD) == 0 && controls[i].getVisible()) { + if ((align & SWT.WRAP) == 0 && (align & SWT.LEAD) == 0 && !controls[i].isDisposed() && controls[i].getVisible()) { Point rightSize = controls[i].computeSize(SWT.DEFAULT, SWT.DEFAULT); width += rightSize.x; } @@ -2456,11 +2456,13 @@ void setButtonBounds(GC gc) { boolean changed = false; ignoreResize = true; for (int i = 0; i < controls.length; i++) { - if (overflow[0][i]) { - controls[i].setBounds(rects[i]); - } else { - controls[i].moveAbove(null); - controls[i].setBounds(rects[i].x, rects[i].y, rects[i].width, headerHeight); + if (!controls[i].isDisposed()) { + if (overflow[0][i]) { + controls[i].setBounds(rects[i]); + } else { + controls[i].moveAbove(null); + controls[i].setBounds(rects[i].x, rects[i].y, rects[i].width, headerHeight); + } } if (!changed && !rects[i].equals(controlRects[i])) changed = true; } @@ -3414,7 +3416,7 @@ public void setTopRight(Control control, int alignment) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } if (topRight == control && topRightAlignment == alignment) return; - if (topRight != null) removeTabControl(topRight, false); + if (topRight != null && !topRight.isDisposed()) removeTabControl(topRight, false); topRight = control; topRightAlignment = alignment; alignment &= ~SWT.RIGHT; @@ -3655,7 +3657,7 @@ boolean updateTabHeight(boolean force){ gc.dispose(); if (fixedTabHeight == SWT.DEFAULT && controls != null && controls.length > 0) { for (int i = 0; i < controls.length; i++) { - if ((controlAlignments[i] & SWT.WRAP) == 0 && controls[i].getVisible()) { + if ((controlAlignments[i] & SWT.WRAP) == 0 && !controls[i].isDisposed() && controls[i].getVisible()) { int topHeight = controls[i].computeSize(SWT.DEFAULT, SWT.DEFAULT).y; topHeight += renderer.computeTrim(CTabFolderRenderer.PART_HEADER, SWT.NONE, 0,0,0,0).height + 1; tabHeight = Math.max(topHeight, tabHeight); @@ -3672,28 +3674,30 @@ void updateBkImages() { if (controls != null && controls.length > 0) { for (int i = 0; i < controls.length; i++) { Control control = controls[i]; - if (hovering) { - if (control instanceof Composite) ((Composite) control).setBackgroundMode(SWT.INHERIT_NONE); - control.setBackgroundImage(null); - control.setBackground(getBackground()); - } else { - if (control instanceof Composite) ((Composite) control).setBackgroundMode(SWT.INHERIT_DEFAULT); - Rectangle bounds = control.getBounds(); - if (bounds.y > getTabHeight() || gradientColors == null) { + if (!control.isDisposed()) { + if (hovering) { + if (control instanceof Composite) ((Composite) control).setBackgroundMode(SWT.INHERIT_NONE); control.setBackgroundImage(null); control.setBackground(getBackground()); } else { - bounds.width = 10; - bounds.y = -bounds.y; - bounds.height -= 2*bounds.y - 1; - bounds.x = 0; - if (controlBkImages[i] != null) controlBkImages[i].dispose(); - controlBkImages[i] = new Image(control.getDisplay(), bounds); - GC gc = new GC(controlBkImages[i]); - renderer.drawBackground(gc, bounds, 0); - gc.dispose(); - control.setBackground(null); - control.setBackgroundImage(controlBkImages[i]); + if (control instanceof Composite) ((Composite) control).setBackgroundMode(SWT.INHERIT_DEFAULT); + Rectangle bounds = control.getBounds(); + if (bounds.y > getTabHeight() || gradientColors == null) { + control.setBackgroundImage(null); + control.setBackground(getBackground()); + } else { + bounds.width = 10; + bounds.y = -bounds.y; + bounds.height -= 2*bounds.y - 1; + bounds.x = 0; + if (controlBkImages[i] != null) controlBkImages[i].dispose(); + controlBkImages[i] = new Image(control.getDisplay(), bounds); + GC gc = new GC(controlBkImages[i]); + renderer.drawBackground(gc, bounds, 0); + gc.dispose(); + control.setBackground(null); + control.setBackgroundImage(controlBkImages[i]); + } } } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderLayout.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderLayout.java index 38998e8258..f7a14117cb 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderLayout.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderLayout.java @@ -44,7 +44,7 @@ protected Point computeSize(Composite composite, int wHint, int hHint, boolean f if (wHint == SWT.DEFAULT) { for (int i = 0; i < folder.controls.length; i++) { Control control = folder.controls[i]; - if (control.getVisible()) { + if (!control.isDisposed() && control.getVisible()) { if ((folder.controlAlignments[i] & SWT.LEAD) != 0) { leftControl = true; } else { |