# Patch for SWT 3.2 final (build 3232) source code
# This patch fixes 2 sets of GDI leaks in Windows 98
#
diff -u6r org/eclipse/swt/custom/CTabFolder.java org/eclipse/swt/custom/CTabFolder.java
--- org/eclipse/swt/custom/CTabFolder.java	2005-12-13 11:18:10.000000000 +0900
+++ org/eclipse/swt/custom/CTabFolder.java	2006-01-19 16:20:58.000000000 +0900
@@ -768,12 +768,13 @@
 		} else {
 			gc.drawLine(x1, y2, x2, y2); // bottom
 		}
 	}
 }
 
+// XXX TuxPaper: store gc's font and restore  (Win98 Resource Leak)
 void drawChevron(GC gc) {
 	if (chevronRect.width == 0 || chevronRect.height == 0) return;
 	// draw chevron (10x7)
 	Display display = getDisplay();
 	Point dpi = display.getDPI();
 	int fontHeight = 72 * 10 / dpi.y;
@@ -796,56 +797,62 @@
 	}
 	String chevronString = count > 99 ? "99+" : String.valueOf(count); //$NON-NLS-1$
 	switch (chevronImageState) {
 		case NORMAL: {
 			Color chevronBorder = single ? getSelectionForeground() : getForeground();
 			gc.setForeground(chevronBorder);
+			Font oldFont = gc.getFont();
 			gc.setFont(f);
 			gc.drawLine(x,y,     x+2,y+2);
 			gc.drawLine(x+2,y+2, x,y+4);
 			gc.drawLine(x+1,y,   x+3,y+2);
 			gc.drawLine(x+3,y+2, x+1,y+4);
 			gc.drawLine(x+4,y,   x+6,y+2);
 			gc.drawLine(x+6,y+2, x+5,y+4);
 			gc.drawLine(x+5,y,   x+7,y+2);
 			gc.drawLine(x+7,y+2, x+4,y+4);
 			gc.drawString(chevronString, x+7, y+3, true);
+			gc.setFont(oldFont);
 			break;
 		}
 		case HOT: {
 			gc.setForeground(display.getSystemColor(BUTTON_BORDER));
 			gc.setBackground(display.getSystemColor(BUTTON_FILL));
+			Font oldFont = gc.getFont();
 			gc.setFont(f);
 			gc.fillRoundRectangle(chevronRect.x, chevronRect.y, chevronRect.width, chevronRect.height, 6, 6);
 			gc.drawRoundRectangle(chevronRect.x, chevronRect.y, chevronRect.width - 1, chevronRect.height - 1, 6, 6);
 			gc.drawLine(x,y,     x+2,y+2);
 			gc.drawLine(x+2,y+2, x,y+4);
 			gc.drawLine(x+1,y,   x+3,y+2);
 			gc.drawLine(x+3,y+2, x+1,y+4);
 			gc.drawLine(x+4,y,   x+6,y+2);
 			gc.drawLine(x+6,y+2, x+5,y+4);
 			gc.drawLine(x+5,y,   x+7,y+2);
 			gc.drawLine(x+7,y+2, x+4,y+4);
 			gc.drawString(chevronString, x+7, y+3, true);
+			gc.setFont(oldFont);
 			break;
 		}
 		case SELECTED: {
 			gc.setForeground(display.getSystemColor(BUTTON_BORDER));
 			gc.setBackground(display.getSystemColor(BUTTON_FILL));
+			Font oldFont = gc.getFont();
 			gc.setFont(f);
 			gc.fillRoundRectangle(chevronRect.x, chevronRect.y, chevronRect.width, chevronRect.height, 6, 6);
 			gc.drawRoundRectangle(chevronRect.x, chevronRect.y, chevronRect.width - 1, chevronRect.height - 1, 6, 6);
 			gc.drawLine(x+1,y+1, x+3,y+3);
 			gc.drawLine(x+3,y+3, x+1,y+5);
 			gc.drawLine(x+2,y+1, x+4,y+3);
 			gc.drawLine(x+4,y+3, x+2,y+5);
 			gc.drawLine(x+5,y+1, x+7,y+3);
 			gc.drawLine(x+7,y+3, x+6,y+5);
 			gc.drawLine(x+6,y+1, x+8,y+3);
 			gc.drawLine(x+8,y+3, x+5,y+5);
 			gc.drawString(chevronString, x+8, y+4, true);
+			gc.setFont(oldFont);
 			break;
 		}
 	}
 	f.dispose();
 }
 void drawMaximize(GC gc) {
diff -u6r org/eclipse/swt/widgets/Widget.java org/eclipse/swt/widgets/Widget.java
--- org/eclipse/swt/widgets/Widget.java	2006-02-01 12:17:21.171875000 +0900
+++ org/eclipse/swt/widgets/Widget.java	2006-02-14 22:57:41.437500000 +0900
@@ -2028,13 +2028,14 @@
 			OS.GetRgnBox (rgn, rect);
 			int width = rect.right - rect.left;
 			int height = rect.bottom - rect.top;
 			if (width != 0 && height != 0) {
 				int hDC = gc.handle;
 				OS.SelectClipRgn (hDC, rgn);
-				OS.SetMetaRgn (hDC);
+				//XXX Win98 Resource Leak
+				//OS.SetMetaRgn (hDC);
 				Event event = new Event ();
 				event.gc = gc;
 				event.x = rect.left;
 				event.y = rect.top;
 				event.width = width;
 				event.height = height;
