comparison dwt/graphics/Resource.d @ 335:47b37f126740

Global flag to disable the dispose checking
author Frank Benoit <benoit@tionex.de>
date Wed, 18 Feb 2009 17:10:51 +0100
parents c49e17d48b76
children
comparison
equal deleted inserted replaced
334:c49e17d48b76 335:47b37f126740
12 *******************************************************************************/ 12 *******************************************************************************/
13 module dwt.graphics.Resource; 13 module dwt.graphics.Resource;
14 14
15 import dwt.DWT; 15 import dwt.DWT;
16 import dwt.graphics.Device; 16 import dwt.graphics.Device;
17 //import tango.util.log.Trace;
18 17
19 /** 18 /**
20 * This class is the abstract superclass of all graphics resource objects. 19 * This class is the abstract superclass of all graphics resource objects.
21 * Resources created by the application must be disposed. 20 * Resources created by the application must be disposed.
22 * <p> 21 * <p>
40 * @since 3.1 39 * @since 3.1
41 */ 40 */
42 public abstract class Resource { 41 public abstract class Resource {
43 42
44 /// DWT extension for D: do no dispose check 43 /// DWT extension for D: do no dispose check
45 bool disposeChecking = true; 44 public bool disposeChecking = true;
45 /// DWT extension for D: do no dispose check
46 public static bool globalDisposeChecking = true;
46 47
47 /** 48 /**
48 * the device where this resource was created 49 * the device where this resource was created
49 */ 50 */
50 Device device; 51 Device device;
57 if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 58 if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
58 this.device = device; 59 this.device = device;
59 } 60 }
60 61
61 ~this(){ 62 ~this(){
62 if( disposeChecking && !isDisposed() ){ 63 if( globalDisposeChecking && disposeChecking && !isDisposed() ){
63 //Trace.formatln("{} {} {} Resource deleted, but is not yet disposed", __FILE__, __LINE__, this.classinfo.name ); 64 DWT.error( 0, null, " Resource deleted, but is not yet disposed. "
64 DWT.error( 0, null, " Resource deleted, but is not yet disposed: (" ~ this.classinfo.name ~ ") " ~ this.toString() ); 65 "This check can be disabled with "
66 "\"import dwt.graphics.Resource; "
67 "Resource.globalDisposeChecking = false; \". "
68 "This problem occured with type " ~ this.classinfo.name ~
69 " this.toString()=" ~ this.toString() );
65 } 70 }
66 } 71 }
67 72
68 void destroy() { 73 void destroy() {
69 } 74 }