diff 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
line wrap: on
line diff
--- a/generator/typesystem_core-java.java	Fri Jul 03 20:53:07 2009 +0000
+++ b/generator/typesystem_core-java.java	Sat Jul 04 13:04:46 2009 +0000
@@ -49,25 +49,30 @@
     public bool __stackAllocated = false;
     
     public bool __qobject_is_deleting = false;
-/*    
-    new(uint size, void* p = null)
+    
+    new(size_t size, void* p = null)
     {
         if (!p)
         {
             p = malloc(size);
             if (!p)
                 assert(false, "Out of memory");
+            GC.addRange(p, size);
         }
-
         return p;
     }
 
     delete(void* p)
     {
-        if (!(cast(typeof(this))p).__stackAllocated)
-            free(p);
+        if(p)
+        {
+            if (!(cast(typeof(this))p).__stackAllocated) {
+                free(p);
+                GC.removeRange(p);
+            }
+        }
     }
-*/    
+    
     // list of QObjects references to prevent them from garbage collecting if they are managed by Qt
     private static QObject[] __gc_ref_list;