# HG changeset patch # User Frank Benoit # Date 1234970071 -3600 # Node ID c49e17d48b76cd7c01f04675f6bb371e1602a6e1 # Parent 684eed7589a0e4784fde134720a2022cadac26c5 Fix problems at GC run at main()'s end. diff -r 684eed7589a0 -r c49e17d48b76 dwt/graphics/Color.d --- a/dwt/graphics/Color.d Tue Feb 10 17:14:24 2009 +0100 +++ b/dwt/graphics/Color.d Wed Feb 18 16:14:31 2009 +0100 @@ -332,6 +332,7 @@ */ public static Color win32_new(Device device, int handle) { Color color = new Color(device); + color.disposeChecking = false; color.handle = handle; return color; } diff -r 684eed7589a0 -r c49e17d48b76 dwt/graphics/Cursor.d --- a/dwt/graphics/Cursor.d Tue Feb 10 17:14:24 2009 +0100 +++ b/dwt/graphics/Cursor.d Wed Feb 18 16:14:31 2009 +0100 @@ -468,6 +468,7 @@ */ public static Cursor win32_new(Device device, HCURSOR handle) { Cursor cursor = new Cursor(device); + cursor.disposeChecking = false; cursor.handle = handle; return cursor; } diff -r 684eed7589a0 -r c49e17d48b76 dwt/graphics/Font.d --- a/dwt/graphics/Font.d Tue Feb 10 17:14:24 2009 +0100 +++ b/dwt/graphics/Font.d Wed Feb 18 16:14:31 2009 +0100 @@ -12,7 +12,6 @@ *******************************************************************************/ module dwt.graphics.Font; - import dwt.DWT; import dwt.DWTError; import dwt.DWTException; @@ -195,9 +194,9 @@ */ public FontData[] getFontData() { if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); - LOGFONT* logFont = new LOGFONT(); - OS.GetObject(handle, LOGFONT.sizeof, logFont); - return [ cast(FontData) FontData.win32_new(logFont, device.computePoints(logFont, handle))]; + LOGFONT logFont; + OS.GetObject(handle, LOGFONT.sizeof, &logFont); + return [ cast(FontData) FontData.win32_new(&logFont, device.computePoints(&logFont, handle))]; } /** @@ -247,6 +246,12 @@ override public String toString () { if (isDisposed()) return "Font {*DISPOSED*}"; return Format( "Font {{{}}", handle ); +// +// LOGFONT logFont; +// OS.GetObject(handle, LOGFONT.sizeof, &logFont); +// char[] name = .TCHARzToStr( logFont.lfFaceName.ptr, -1 ); +// +// return Format( "Font {{{}, {}}", handle, name ); } /** @@ -265,6 +270,7 @@ */ public static Font win32_new(Device device, HFONT handle) { Font font = new Font(device); + font.disposeChecking = false; font.handle = handle; return font; } diff -r 684eed7589a0 -r c49e17d48b76 dwt/graphics/GC.d --- a/dwt/graphics/GC.d Tue Feb 10 17:14:24 2009 +0100 +++ b/dwt/graphics/GC.d Wed Feb 18 16:14:31 2009 +0100 @@ -4893,6 +4893,7 @@ public static GC win32_new(Drawable drawable, GCData data) { GC gc = new GC(); auto hDC = drawable.internal_new_GC(data); + gc.disposeChecking = false; gc.device = data.device; gc.init_(drawable, data, hDC); return gc; @@ -4915,6 +4916,7 @@ */ public static GC win32_new(HDC hDC, GCData data) { GC gc = new GC(); + gc.disposeChecking = false; gc.device = data.device; data.style |= DWT.LEFT_TO_RIGHT; if (OS.WIN32_VERSION >= OS.VERSION (4, 10)) { diff -r 684eed7589a0 -r c49e17d48b76 dwt/graphics/Image.d --- a/dwt/graphics/Image.d Tue Feb 10 17:14:24 2009 +0100 +++ b/dwt/graphics/Image.d Wed Feb 18 16:14:31 2009 +0100 @@ -2152,6 +2152,7 @@ */ public static Image win32_new(Device device, int type, HGDIOBJ handle) { Image image = new Image(device); + image.disposeChecking = false; image.type = type; image.handle = handle; return image; diff -r 684eed7589a0 -r c49e17d48b76 dwt/graphics/Region.d --- a/dwt/graphics/Region.d Tue Feb 10 17:14:24 2009 +0100 +++ b/dwt/graphics/Region.d Wed Feb 18 16:14:31 2009 +0100 @@ -604,7 +604,9 @@ * @return a new region object containing the specified device and handle */ public static Region win32_new(Device device, HRGN handle) { - return new Region(device, handle); + auto region = new Region(device, handle); + region.disposeChecking = false; + return region; } } diff -r 684eed7589a0 -r c49e17d48b76 dwt/graphics/Resource.d --- a/dwt/graphics/Resource.d Tue Feb 10 17:14:24 2009 +0100 +++ b/dwt/graphics/Resource.d Wed Feb 18 16:14:31 2009 +0100 @@ -41,6 +41,9 @@ */ public abstract class Resource { + /// DWT extension for D: do no dispose check + bool disposeChecking = true; + /** * the device where this resource was created */ @@ -56,9 +59,9 @@ } ~this(){ - if( !isDisposed ){ + if( disposeChecking && !isDisposed() ){ //Trace.formatln("{} {} {} Resource deleted, but is not yet disposed", __FILE__, __LINE__, this.classinfo.name ); - DWT.error( 0, null, " Resource deleted, but is not yet disposed: (" ~ this.classinfo.name ~ ")" ); + DWT.error( 0, null, " Resource deleted, but is not yet disposed: (" ~ this.classinfo.name ~ ") " ~ this.toString() ); } }