comparison generator/typesystem_core-java.java @ 184:7d9db724ee1d

QObject is now non GC'ed, to better integrate to Qt memory management
author eldar
date Sat, 04 Jul 2009 13:04:46 +0000
parents d3f4f14d43a5
children 4fcf7ba2a791
comparison
equal deleted inserted replaced
183:d3f4f14d43a5 184:7d9db724ee1d
47 class QObject___ extends QObject { 47 class QObject___ extends QObject {
48 48
49 public bool __stackAllocated = false; 49 public bool __stackAllocated = false;
50 50
51 public bool __qobject_is_deleting = false; 51 public bool __qobject_is_deleting = false;
52 /* 52
53 new(uint size, void* p = null) 53 new(size_t size, void* p = null)
54 { 54 {
55 if (!p) 55 if (!p)
56 { 56 {
57 p = malloc(size); 57 p = malloc(size);
58 if (!p) 58 if (!p)
59 assert(false, "Out of memory"); 59 assert(false, "Out of memory");
60 GC.addRange(p, size);
60 } 61 }
61
62 return p; 62 return p;
63 } 63 }
64 64
65 delete(void* p) 65 delete(void* p)
66 { 66 {
67 if (!(cast(typeof(this))p).__stackAllocated) 67 if(p)
68 free(p); 68 {
69 } 69 if (!(cast(typeof(this))p).__stackAllocated) {
70 */ 70 free(p);
71 GC.removeRange(p);
72 }
73 }
74 }
75
71 // list of QObjects references to prevent them from garbage collecting if they are managed by Qt 76 // list of QObjects references to prevent them from garbage collecting if they are managed by Qt
72 private static QObject[] __gc_ref_list; 77 private static QObject[] __gc_ref_list;
73 78
74 // this flag controls whether QObject is managed by D's GC, or it has a parent and therefore managed by Qt 79 // this flag controls whether QObject is managed by D's GC, or it has a parent and therefore managed by Qt
75 private bool __gc_managed = true; 80 private bool __gc_managed = true;