changeset 252:37eed70de029

More things broken than fixed. Rolling back to 263
author maxter
date Sat, 22 Aug 2009 12:50:58 +0000
parents 739d0ee5bd91
children 073b9153ed8a
files CMakeLists.txt build/core.makefile build/core.txt cpp/qt_core/QMetaObject_shell.cpp cpp/qt_core/QVariant_shell.cpp cpp/qt_gui/UrlHandler_shell.cpp cpp/qt_gui/UrlHandler_shell.h cpp/qt_qtd/ArrayOpsPrimitive_shell.cpp cpp/qt_qtd/qtd_core.cpp generator/containergenerator.cpp generator/cppheadergenerator.cpp generator/cppimplgenerator.cpp generator/cppimplgenerator.h generator/dgenerator.cpp generator/dgenerator.h generator/fileout.h generator/typesystem_core-java.java generator/typesystem_core-java.xml generator/typesystem_core.xml generator/typesystem_gui-java.java generator/typesystem_gui-java.xml generator/typesystem_gui.xml generator/typesystem_network-java.xml generator/typesystem_network.xml generator/typesystem_opengl-java.xml generator/typesystem_opengl.xml generator/typesystem_sql.xml generator/typesystem_svg-java.xml generator/typesystem_svg.xml generator/typesystem_webkit-java.xml generator/typesystem_webkit.xml generator/typesystem_xml.xml include/QObjectEntity.h include/qtd_core.h qt/CMakeLists.txt qt/QDefines.d qt/QGlobal.d qt/core/QMetaObject.d qt/d1/qt/QtDObject.d qt/d1/qt/QtdObject.d qt/d1/qt/core/QLine.d qt/d1/qt/core/QModelIndex.d qt/d1/qt/core/QPoint.d qt/d1/qt/core/QRect.d qt/d1/qt/core/QRectF.d qt/d1/qt/core/QVariant.d qt/d1/qt/qtd/Str.d qt/d2/qt/QtDObject.d qt/d2/qt/QtdObject.d qt/d2/qt/core/QLine.d qt/d2/qt/core/QModelIndex.d qt/d2/qt/core/QPoint.d qt/d2/qt/core/QRect.d qt/d2/qt/core/QRectF.d qt/d2/qt/core/QVariant.d qt/d2/qt/qtd/Str.d qt/qtd/Traits.d
diffstat 57 files changed, 1118 insertions(+), 1259 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Thu Aug 20 19:08:32 2009 +0000
+++ b/CMakeLists.txt	Sat Aug 22 12:50:58 2009 +0000
@@ -15,7 +15,7 @@
 Please delete them.
 
   Or you can restart cmake with `-DALLOW_IN_SOURCE_BUILDS=1`, but it is not
-recommended.
+recomended.
 ")
 endif(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT ALLOW_IN_SOURCE_BUILDS)
 
@@ -389,11 +389,7 @@
 	endforeach(d_source ${d_generated_files})
 	set(classes ArrayOps ${classes})
 	foreach(class ${classes})
-	    set(d_sources ${d_sources} ${CMAKE_BINARY_DIR}/qt/${package}/${class}.d)
-	    set(aux_name ${CMAKE_BINARY_DIR}/qt/${package}/${class}_aux.d )
-            if(EXISTS ${aux_name})
-	        set(d_sources ${d_sources} ${aux_name})
-	    endif(EXISTS ${aux_name})
+	    set(d_sources ${d_sources} ${CMAKE_BINARY_DIR}/qt/${package}/${class}.d)	
 	    set(cpp_sources ${cpp_sources} ${CMAKE_BINARY_DIR}/cpp/qt_${package}/${class}_shell.cpp) 
 	endforeach(class ${classes})
 	set(files_for_gen ${files_for_gen} ${cpp_sources} ${d_sources})
@@ -421,7 +417,7 @@
 	      set(regexp_str_tmp "(${ver_safe_tmp}/|${cbd_safe_tmp}/|${csd_safe_tmp}/|)(.+)")
 	      string(REGEX REPLACE ${regexp_str_tmp} "\\2" ins_path "${path}") 
 	      install(FILES ${d_source} DESTINATION include/d/${ins_path} COMPONENT qtd RENAME ${name}.di)
-	      install(FILES ${path}/${name}_aux.d DESTINATION include/d/${ins_path} COMPONENT qtd RENAME ${name}_aux.di OPTIONAL)
+	      install(FILES ${path}/${name}_enum.d DESTINATION include/d/${ins_path} COMPONENT qtd RENAME ${name}_enum.di OPTIONAL)
 	    endforeach(d_source ${d_sources})
 	endif(NOT GENERATE_DI_FILES)
 
--- a/build/core.makefile	Thu Aug 20 19:08:32 2009 +0000
+++ b/build/core.makefile	Sat Aug 22 12:50:58 2009 +0000
@@ -5,7 +5,7 @@
 endif
 
 ##--------------------------
-QTD_CORE += QGlobal $(D_PATH)/qtd/Str core/Qt qtd/ArrayOpsPrimitive $(D_PATH)/QtdObject $(D_PATH)/Signal \
+QTD_CORE += QGlobal $(D_PATH)/qtd/Str core/Qt qtd/ArrayOpsPrimitive $(D_PATH)/QtDObject $(D_PATH)/Signal \
 $(D_PATH)/core/QPoint \
 $(D_PATH)/core/QPointF \
 $(D_PATH)/core/QRect \
--- a/build/core.txt	Thu Aug 20 19:08:32 2009 +0000
+++ b/build/core.txt	Sat Aug 22 12:50:58 2009 +0000
@@ -7,19 +7,13 @@
     qt_core/QLine_shell qt_core/QLineF_shell
     qt_core/QRect_shell qt_core/QRectF_shell
     qt_core/QString_shell qt_core/QVariant_shell
-    qt_core/QModelIndex_shell qt_core/QMetaType_shell
-    qt_core/QMetaObject_shell)
+    qt_core/QModelIndex_shell qt_core/QMetaType_shell)
 ## Module specific d files.
-set (d_files
-    QGlobal
-    qtd/Array  
+set (d_files QGlobal qtd/Array  
     qtd/ArrayOpsPrimitive   
-    qtd/Traits
-    core/QString
-    core/QMetaType
-    core/QMetaObject)
+    core/QString core/QMetaType)
 set (d_version_files 
-    QtdObject
+    QtDObject
     Signal qtd/Str
     core/QLine core/QLineF
     core/QModelIndex
--- a/cpp/qt_core/QMetaObject_shell.cpp	Thu Aug 20 19:08:32 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-#include "qtd_core.h"
-#include <qobjectdefs.h>
-
-extern "C" DLL_PUBLIC void* qtd_QMetaObject_superClass(void *nativeId)
-{
-    return (void*)((QMetaObject*)nativeId)->superClass();
-}
\ No newline at end of file
--- a/cpp/qt_core/QVariant_shell.cpp	Thu Aug 20 19:08:32 2009 +0000
+++ b/cpp/qt_core/QVariant_shell.cpp	Sat Aug 22 12:50:58 2009 +0000
@@ -857,7 +857,7 @@
     QVariant_QtDShell *__qt_this = (QVariant_QtDShell *) __this_nativeId;
     QString  __qt_return_value = __qt_this->toString();
 
-    qtd_toUtf8(__qt_return_value.utf16(), __qt_return_value.size(), __java_return_value);
+    _d_toUtf8(__qt_return_value.utf16(), __qt_return_value.size(), __java_return_value);
 
 }
 
--- a/cpp/qt_gui/UrlHandler_shell.cpp	Thu Aug 20 19:08:32 2009 +0000
+++ b/cpp/qt_gui/UrlHandler_shell.cpp	Sat Aug 22 12:50:58 2009 +0000
@@ -4,19 +4,19 @@
 
 UrlHandler::UrlHandler(void *d_ptr, QObject*  parent0)
     : QObject(parent0),
-      QtD_QObjectEntity(this, d_ptr)
+      Qtd_QObjectEntity(d_ptr)
 {
 }
 
 #ifdef CPP_SHARED
-extern "C" typedef void (*pfqtd_UrlHandler_handleUrl_QUrl_dispatch)(void *dId, void* arg__1);
+extern "C" typedef void (*pfqtd_UrlHandler_handleUrl_QUrl_dispatch)(void *d_entity, void* arg__1);
 pfqtd_UrlHandler_handleUrl_QUrl_dispatch qtd_UrlHandler_handleUrl_QUrl_dispatch;
 #else
-extern "C" void qtd_UrlHandler_handleUrl_QUrl_dispatch(void *dId, void* name1);
+extern "C" void qtd_UrlHandler_handleUrl_QUrl_dispatch(void *d_entity, void* name1);
 #endif
 void UrlHandler::handleUrl(const QUrl &url)
 {
-    qtd_UrlHandler_handleUrl_QUrl_dispatch(this->dId, &(QUrl& )url);
+    qtd_UrlHandler_handleUrl_QUrl_dispatch(this->d_entity(), &(QUrl& )url);
 }
 
 extern "C" DLL_PUBLIC void qtd_UrlHandler_destructor(void *ptr)
--- a/cpp/qt_gui/UrlHandler_shell.h	Thu Aug 20 19:08:32 2009 +0000
+++ b/cpp/qt_gui/UrlHandler_shell.h	Sat Aug 22 12:50:58 2009 +0000
@@ -1,7 +1,7 @@
 #include <QUrl>
 #include <QObjectEntity.h>
 
-class UrlHandler : public QObject, public QtD_QObjectEntity
+class UrlHandler : public QObject, public Qtd_QObjectEntity
 {
     Q_OBJECT
 
--- a/cpp/qt_qtd/ArrayOpsPrimitive_shell.cpp	Thu Aug 20 19:08:32 2009 +0000
+++ b/cpp/qt_qtd/ArrayOpsPrimitive_shell.cpp	Sat Aug 22 12:50:58 2009 +0000
@@ -37,15 +37,15 @@
     QTD_EXPORT_VAR_SET(qtd_allocate_int_array, callbacks[0]);
     QTD_EXPORT_VAR_SET(qtd_assign_int_array_element, callbacks[1]);
     QTD_EXPORT_VAR_SET(qtd_get_int_from_array, callbacks[2]);
-
+    
     QTD_EXPORT_VAR_SET(qtd_allocate_uint_array, callbacks[3]);
     QTD_EXPORT_VAR_SET(qtd_assign_uint_array_element, callbacks[4]);
     QTD_EXPORT_VAR_SET(qtd_get_uint_from_array, callbacks[5]);
-
+    
     QTD_EXPORT_VAR_SET(qtd_allocate_double_array, callbacks[6]);
     QTD_EXPORT_VAR_SET(qtd_assign_double_array_element, callbacks[7]);
     QTD_EXPORT_VAR_SET(qtd_get_double_from_array, callbacks[8]);
-
+    
     QTD_EXPORT_VAR_SET(qtd_allocate_string_array, callbacks[9]);
     QTD_EXPORT_VAR_SET(qtd_assign_string_array_element, callbacks[10]);
     QTD_EXPORT_VAR_SET(qtd_string_from_array, callbacks[11]);
--- a/cpp/qt_qtd/qtd_core.cpp	Thu Aug 20 19:08:32 2009 +0000
+++ b/cpp/qt_qtd/qtd_core.cpp	Sat Aug 22 12:50:58 2009 +0000
@@ -40,13 +40,13 @@
 }
 
 #ifdef CPP_SHARED
-QTD_EXPORT_VAR(qtd_toUtf8);
-QTD_EXPORT_VAR(qtd_dummy);
+QTD_EXPORT_VAR(_d_toUtf8)
+QTD_EXPORT_VAR(__qtd_dummy)
 
-extern "C" DLL_PUBLIC void qtd_core_initCallBacks(pfunc_abstr d_func, pfunc_abstr dummy) {
-    QTD_EXPORT_VAR_SET(qtd_toUtf8, d_func);
-    QTD_EXPORT_VAR_SET(qtd_dummy, dummy);
-    //std::cout << "qtd_core initialized" << std::endl;
+extern "C" DLL_PUBLIC void __qtd_qtd_core_initCallBacks(pfunc_abstr d_func, pfunc_abstr dummy) {
+    QTD_EXPORT_VAR_SET(_d_toUtf8, d_func);
+    QTD_EXPORT_VAR_SET(__qtd_dummy, dummy);
+//    std::cout << _d_toUtf8 << "\n";
 }
 #endif
 
--- a/generator/containergenerator.cpp	Thu Aug 20 19:08:32 2009 +0000
+++ b/generator/containergenerator.cpp	Sat Aug 22 12:50:58 2009 +0000
@@ -447,7 +447,7 @@
         d_type = cls_name;
         if (centry->designatedInterface())
             d_type = centry->designatedInterface()->name();
-        nativeId = ".__nativeId";
+        nativeId = ".nativeId";
     }
 
     if (centry->designatedInterface()) {
@@ -470,7 +470,7 @@
       << INDENT << "*elem = arr[pos]" << nativeId << ";" << endl
       << "}" << endl << endl
 
-      << "package " << d_type << " qtd_" << cls_name << "_cpp_to_d(" << cpp_type << " ret)" << endl
+      << "package " << d_type << " qtd_" << cls_name << "_cpp_to_d(" << cpp_type << " __qt_return_value)" << endl
       << "{" << endl;
 
     marshallFromCppToD(s, centry);
--- a/generator/cppheadergenerator.cpp	Thu Aug 20 19:08:32 2009 +0000
+++ b/generator/cppheadergenerator.cpp	Sat Aug 22 12:50:58 2009 +0000
@@ -178,15 +178,13 @@
 
     s << "class " << shellClassName(java_class)
       << " : public " << java_class->qualifiedCppName();
-    if (java_class->isQObject())
-        s << ", public QtD_QObjectEntity";
-    else if(java_class->hasVirtualFunctions())
-        s << ", public QtD_Entity";
+    if (java_class->hasVirtualFunctions())
+        s << ", public Qtd_QObjectEntity";
     s << endl  << "{" << endl;
 
     if (java_class->isQObject()) {
       s << "public:" << endl
-        << "  Q_OBJECT_CHECK" << endl
+        << "  Q_OBJECT_CHECK" << endl;
 //        << "  mutable const QMetaObject *m_meta_object;" << endl;
 
 /*      if (java_class->hasVirtualSlots()) {
@@ -195,9 +193,9 @@
 */
 //      s << "  const QMetaObject *metaObject() const;" << endl
 //        << "  void *qt_metacast(const char *);" << endl
-//        << "  QT_TR_FUNCTIONS" << end
-      << "  virtual int qt_metacall(QMetaObject::Call, int, void **);" << endl
-      << "private:" << endl;
+//        << "  QT_TR_FUNCTIONS" << endl
+//        << "  virtual int qt_metacall(QMetaObject::Call, int, void **);" << endl
+      s << "private:" << endl;
     }
 
 
--- a/generator/cppimplgenerator.cpp	Thu Aug 20 19:08:32 2009 +0000
+++ b/generator/cppimplgenerator.cpp	Sat Aug 22 12:50:58 2009 +0000
@@ -465,6 +465,26 @@
     return !java_class->isQObject() && !java_class->typeEntry()->isValue();
 }
 
+void writeQtdEntityFunction(QTextStream &s, const AbstractMetaClass *java_class)
+{
+//    if (!(java_class->typeEntry()->isObject() || java_class->typeEntry()->isQObject()))
+//        return;
+    if (!java_class->hasVirtualFunctions())
+        return;
+
+    s << "extern \"C\" DLL_PUBLIC void *__" << java_class->name() << "_entity(void *q_ptr)" << endl;
+    s << "{" << endl;
+    {
+        Indentation indent(INDENT);
+            s << INDENT << "Qtd_QObjectEntity* a = dynamic_cast<Qtd_QObjectEntity*>((" << java_class->qualifiedCppName() << "*)q_ptr);" << endl
+              << INDENT << "if (a != NULL)" << endl
+              << INDENT << "    return a->d_entity();" << endl
+              << INDENT << "else" << endl
+              << INDENT << "    return NULL;" << endl;
+    }
+    s << "}" << endl << endl;
+}
+
 void CppImplGenerator::writeInterfaceCasts(QTextStream &s, const AbstractMetaClass *java_class)
 {
         // pointers to native interface objects for classes that implement interfaces
@@ -512,6 +532,11 @@
         s << "    emit_callbacks_" << java_class->name() << "[" << i << "] = (EmitCallback)"
              "sigs[" << i << "];" << endl;
 
+    if (java_class->isQObject())
+        s << "    qtd_D_" << java_class->name() << "_delete = "
+             "(qtd_pf_D_" << java_class->name() << "_delete)qobj_del;" << endl;
+
+
     s << "}" << endl;
 }
 
@@ -583,8 +608,7 @@
     writeDefaultConstructedValues(s, java_class);
 
     if (hasCustomDestructor(java_class)) */
-    if (!java_class->isQObject())
-        writeFinalDestructor(s, java_class);
+    writeFinalDestructor(s, java_class);
 
     if (java_class->isQObject())
         writeSignalsHandling(s, java_class);
@@ -596,8 +620,7 @@
         }
         writeShellDestructor(s, java_class);
 
-        if (!java_class->isQObject() && java_class->hasVirtualFunctions())
-            writeQtdEntityFunction(s, java_class);
+        writeQtdEntityFunction(s, java_class);
 
         if (java_class->isQObject())
             writeQObjectFunctions(s, java_class);
@@ -700,14 +723,6 @@
 */
 // qtd    writeJavaLangObjectOverrideFunctions(s, java_class);
 
-    if (java_class->isQObject())
-    {
-        s << endl << endl
-          << "extern \"C\" DLL_PUBLIC void* qtd_" << java_class->name() << "_staticMetaObject() {" << endl
-          << "    return (void*)&" << java_class->name() << "::staticMetaObject;" << endl
-          << "}" << endl;
-    }
-
     s << endl << endl;
 
     priGenerator->addSource(java_class->package(), fileNameForClass(java_class));
@@ -823,7 +838,7 @@
                 }
 
                 s << function->marshalledName() << "_dispatch("
-                  << "this->dId";
+                  << "this->d_entity()";
 
                 if (f_type) {
                     if (f_type->isTargetLangString())
@@ -846,7 +861,7 @@
                     if (f_type->name() == "QModelIndex") {
                         s << INDENT << "QModelIndex __qt_return_value = qtd_to_QModelIndex( __d_return_value );" << endl;
 #ifdef Q_OS_WIN32
-s << "qtd_dummy();" << endl; // hack!!!
+s << "__qtd_dummy();" << endl; // hack!!!
 #endif
                         s << INDENT << "return __qt_return_value;" << endl;
                     } else if (f_type->typeEntry()->isStructInD())
@@ -1242,16 +1257,21 @@
       << "  return " << java_class->qualifiedCppName() << "::qt_metacast(_clname);" << endl
       << "}" << endl << endl;
 */
-    
+
+//    writeSignalsHandling(s, java_class);
+/*
+    // QObject_Link::qt_metacall()
     s << "int " << shellClassName(java_class) << "::qt_metacall(QMetaObject::Call _c, int _id, void **_a)" << endl
       << "{" << endl;
 
     s << "    _id = " << java_class->qualifiedCppName() << "::qt_metacall(_c, _id, _a);" << endl
       << "    if (_id < 0 || _c != QMetaObject::InvokeMetaMethod)" << endl
       << "        return _id;" << endl
-      << "    emit_callbacks_" << java_class->name() << "[_id](this->dId, _a);" << endl
+//      << "    Q_ASSERT(_id < 2);" << endl
+      << "    emit_callbacks_" << java_class->name() << "[_id](this->d_entity(), _a);" << endl
       << "    return -1;" << endl
       << "}" << endl << endl;
+*/
 }
 
 void CppImplGenerator::writeSignalHandler(QTextStream &s, const AbstractMetaClass *d_class, AbstractMetaFunction *function)
@@ -1296,6 +1316,65 @@
 
 }
 
+void CppImplGenerator::writeQObjectLink(QTextStream &s, const AbstractMetaClass *java_class)
+{
+    QString linkName = java_class->name() + "_Link";
+    QString className = java_class->name();
+
+    if (cpp_shared)
+        s << "extern \"C\" typedef void (*qtd_pf_D_" << java_class->name() << "_delete)(void *d_ptr);" << endl
+          << "qtd_pf_D_" << java_class->name() << "_delete qtd_D_" << java_class->name() << "_delete;" << endl << endl;
+    else
+        s << "extern \"C\" void qtd_D_" << java_class->name() << "_delete(void *d_ptr);" << endl << endl;
+
+    s << "class " << linkName << " : public QObject, public QObjectUserData" << endl
+      << "{" << endl
+      << "public:" << endl
+      << "    Q_OBJECT_CHECK" << endl
+      << "    virtual int qt_metacall(QMetaObject::Call, int, void **);" << endl << endl
+
+      << "    " << linkName << "(QObject *parent, void *d_ptr) : QObject() { _d_ptr = d_ptr; }" << endl
+      << "    ~" << linkName << "() { qtd_D_" << className << "_delete(_d_ptr); }" << endl
+      << "    void *d_entity() const { return _d_ptr; }" << endl << endl
+
+      << "private:" << endl
+      << "    void *_d_ptr;" << endl
+      << "};" << endl << endl;
+
+    // QObject_Link::qt_metacall()
+    s << "int " << linkName << "::qt_metacall(QMetaObject::Call _c, int _id, void **_a)" << endl
+      << "{" << endl
+      << "    _id = QObject::qt_metacall(_c, _id, _a);" << endl
+      << "    if (_id < 0 || _c != QMetaObject::InvokeMetaMethod)" << endl
+      << "        return _id;" << endl
+//      << "    Q_ASSERT(_id < 2);" << endl
+      << "    emit_callbacks_" << java_class->name() << "[_id](this->d_entity(), _a);" << endl
+      << "    return -1;" << endl
+      << "}" << endl << endl;
+
+    s << QString("inline %1_Link *get_%1_link(%1 *obj)").arg(className) << endl
+      << "{" << endl
+      << "    return static_cast<" << linkName << "*>(obj->userData(USER_DATA_ID));" << endl
+      << "}" << endl << endl;
+
+    s << QString("extern \"C\" DLL_PUBLIC void* qtd_%1_d_pointer(%1 *obj)").arg(className) << endl
+      << "{" << endl
+      << "    if (obj->userData(USER_DATA_ID)) {" << endl
+      << "        " << QString("%1_Link *qobj_helper = get_%1_link(obj);").arg(className) << endl
+      << "        return qobj_helper->d_entity();" << endl
+      << "    } else" << endl
+      << "        return NULL;" << endl
+      << "}" << endl << endl;
+
+    s << QString("extern \"C\" DLL_PUBLIC void qtd_%1_create_link(%1 *obj, void* d_obj)").arg(className) << endl
+      << "{" << endl
+      << "    if(obj->userData(USER_DATA_ID))" << endl
+      << "        return;" << endl
+      << "    " << QString("%1 *qobj_link = new %1(obj, d_obj);").arg(linkName) << endl
+      << "    obj->setUserData(USER_DATA_ID, qobj_link);" << endl
+      << "}" << endl << endl;
+}
+
 void CppImplGenerator::writeSignalsHandling(QTextStream &s, const AbstractMetaClass *java_class)
 {
     s << "extern \"C\" typedef void (*EmitCallback)(void*, void**);" << endl;
@@ -1327,6 +1406,8 @@
         s << endl << "};" << endl << endl;
     }
 
+    writeQObjectLink(s, java_class);
+
     // Functions connecting/disconnecting shell's slots
     for(int i = 0; i < signal_funcs.size(); i++) {
         AbstractMetaFunction *signal = signal_funcs.at(i);
@@ -1336,16 +1417,18 @@
           << "(void* native_id)" << endl << "{" << endl
           << "    " << shellClassName(java_class) << " *qobj = (" << shellClassName(java_class) << "*) native_id;" << endl
           << "    const QMetaObject &mo = " << java_class->name() << "::staticMetaObject;" << endl
+          << "    const QMetaObject &mo2 = " << java_class->name() << "_Link::staticMetaObject;" << endl
           << "    int signalId = mo.indexOfSignal(\"" << signal->minimalSignature() << "\");" << endl
-          << "    mo.connect(qobj, signalId, qobj, mo.methodCount() + " << i << ");" << endl
+          << "    mo.connect(qobj, signalId, get_" << java_class->name() << "_link(qobj), mo2.methodCount() + " << i << ");" << endl
           << "}" << endl;
 
         s << "extern \"C\" DLL_PUBLIC void " << sigExternName << "_disconnect"
           << "(void* native_id)" << endl << "{" << endl
           << "    " << shellClassName(java_class) << " *qobj = (" << shellClassName(java_class) << "*) native_id;" << endl
           << "    const QMetaObject &mo = " << shellClassName(java_class) << "::staticMetaObject;" << endl
+          << "    const QMetaObject &mo2 = " << java_class->name() << "_Link::staticMetaObject;" << endl
           << "    int signalId = mo.indexOfSignal(\"" << signal->minimalSignature() << "\");" << endl
-          << "    mo.disconnect(qobj, signalId, qobj, mo.methodCount() + " << i << ");" << endl
+          << "    mo.disconnect(qobj, signalId, get_" << java_class->name() << "_link(qobj), mo2.methodCount() + " << i << ");" << endl
           << "}" << endl << endl;
     }
 }
@@ -1369,10 +1452,8 @@
             s << ", ";
     }
     s << ")";
-    if (cls->isQObject())
-        s << "," << endl << "      QtD_QObjectEntity(this, d_ptr)";
-    else if (cls->hasVirtualFunctions())
-        s << "," << endl << "      QtD_Entity(d_ptr)";
+    if (cls->hasVirtualFunctions())
+        s << "," << endl << "      Qtd_QObjectEntity(d_ptr)";
 /* qtd        s << "    m_meta_object(0)," << endl;
     s << "      m_vtable(0)," << endl
       << "      m_link(0)" << endl;
@@ -1381,7 +1462,6 @@
     s << "{" << endl;
     {
         Indentation indent(INDENT);
-
         writeCodeInjections(s, java_function, cls, CodeSnip::Beginning, TypeSystem::ShellCode);
         writeCodeInjections(s, java_function, cls, CodeSnip::End, TypeSystem::ShellCode);
     }
@@ -1394,8 +1474,35 @@
       << shellClassName(java_class) << "()" << endl
       << "{" << endl;
     {
-        if (java_class->isQObject())
-            s << "    setUserData(userDataId, NULL);";
+/* qtd
+        Indentation indent(INDENT);
+
+        s << "#ifdef QT_DEBUG" << endl
+          << INDENT << "if (m_vtable)" << endl
+          << INDENT << "    m_vtable->deref();" << endl
+          << "#endif" << endl
+          << INDENT << "if (m_link) {" << endl;
+
+        AbstractMetaClassList interfaces = java_class->interfaces();
+        if (interfaces.size() + (java_class->baseClass() != 0 ? 1 : 0) > 1) {
+            if (java_class->baseClass() != 0)
+                interfaces += java_class->baseClass();
+            foreach (AbstractMetaClass *iface, interfaces) {
+                AbstractMetaClass *impl = iface->isInterface() ? iface->primaryInterfaceImplementor() : iface;
+                s << INDENT << "    m_link->unregisterSubObject((" << impl->qualifiedCppName() << " *) this);" << endl;
+            }
+        }
+
+        if (!java_class->isQObject()) {
+            s << INDENT << "    JNIEnv *__jni_env = qtjambi_current_environment();" << endl
+              << INDENT << "    if (__jni_env != 0) m_link->nativeShellObjectDestroyed(__jni_env);" << endl;
+        }
+
+#if defined(QTJAMBI_DEBUG_TOOLS)
+        s << INDENT << "    qtjambi_increase_shellDestructorCalledCount(QString::fromLatin1(\"" << java_class->name() << "\"));" << endl;
+#endif
+
+         s << INDENT << "}" << endl; */
     }
     s << "}" << endl << endl;
 }
@@ -1711,20 +1818,6 @@
     s << "}" << endl << endl;
 }
 
-void CppImplGenerator::writeQtdEntityFunction(QTextStream &s, const AbstractMetaClass *java_class)
-{
-    s << "extern \"C\" DLL_PUBLIC void *__" << java_class->name() << "_entity(void *q_ptr)" << endl;
-    s << "{" << endl;
-    {
-        Indentation indent(INDENT);
-            s << INDENT << "QtD_Entity* a = dynamic_cast<QtD_Entity*>((" << java_class->qualifiedCppName() << "*)q_ptr);" << endl
-              << INDENT << "if (a != NULL)" << endl
-              << INDENT << "    return a->dId;" << endl
-              << INDENT << "else" << endl
-              << INDENT << "    return NULL;" << endl;
-    }
-    s << "}" << endl << endl;
-}
 
 void CppImplGenerator::writeVirtualFunctionOverride(QTextStream &s,
                                                     const AbstractMetaFunction *java_function,
@@ -2063,11 +2156,8 @@
                 function_prefix = "__override_";
                 extra_param.append("__do_static_call");
                 s << INDENT
-                  << "bool __do_static_call = __this_nativeId ? ";
-                if (java_class->isQObject())
-                    s << "QtD_QObjectEntity::getQObjectEntity((QObject*)__this_nativeId) : false;" << endl;
-                else
-                    s << "__" << java_class->name() << "_entity(__this_nativeId) : false;" << endl;
+                  << "bool __do_static_call = __this_nativeId ? "
+                  << "__" << java_class->name() << "_entity(__this_nativeId) : false;" << endl;
             } else {
                 option = OriginalName;
             }
@@ -2124,7 +2214,7 @@
         AbstractMetaType *d_type = argument->type();
         const TypeEntry *te = d_type->typeEntry();
         if ((te && d_type->isNativePointer() && te->name() == "QString"))
-            s << QString("    qtd_toUtf8(__qt_%1.utf16(), __qt_%1.size(), &%1);").arg(argument->indexedName()) << endl;
+            s << QString("    _d_toUtf8(__qt_%1.utf16(), __qt_%1.size(), &%1);").arg(argument->indexedName()) << endl;
     }
 }
 
@@ -2276,7 +2366,25 @@
         s << INDENT << "extern \"C\" DLL_PUBLIC void qtd_" << cls->name() << "_destructor(void *ptr)" << endl
           << INDENT << "{" << endl;
         {
+            Indentation indent(INDENT);
+/* qtd
+            if (!cls->isQObject() && !cls->generateShellClass()) {
+                s << INDENT << "QtJambiLink *link = QtJambiLink::findLinkForUserObject(ptr);" << endl
+                  << INDENT << "if (link) link->resetObject(qtjambi_current_environment());" << endl;
+            }
+
+            // Code injectsions...
+            foreach (const CodeSnip &snip, cls->typeEntry()->codeSnips()) {
+                if (snip.language == TypeSystem::DestructorFunction) {
+                    s << snip.code();
+                }
+            }
+*/
             s << INDENT << "delete (" << shellClassName(cls) << " *)ptr;" << endl;
+
+#if defined(QTJAMBI_DEBUG_TOOLS)
+            s << INDENT << "qtjambi_increase_destructorFunctionCalledCount(QString::fromLatin1(\"" << cls->name() << "\"));" << endl;
+#endif
         }
 
         s << INDENT << "}" << endl << endl;
@@ -2972,13 +3080,13 @@
         if(java_type->typeEntry()->qualifiedCppName() == "QStringRef") {
             s << INDENT << "const QString *str_ref = " << qt_name << ".string();" << endl
               << INDENT << "if(str_ref)" << endl
-              << INDENT << "    qtd_toUtf8(str_ref->utf16(), str_ref->size(), " << java_name << ");" << endl
+              << INDENT << "    _d_toUtf8(str_ref->utf16(), str_ref->size(), " << java_name << ");" << endl
               << INDENT << "else {" << endl
               << INDENT << "    QString empty_str;" << endl
-              << INDENT << "    qtd_toUtf8(empty_str.utf16(), empty_str.size(), " << java_name << ");" << endl
+              << INDENT << "    _d_toUtf8(empty_str.utf16(), empty_str.size(), " << java_name << ");" << endl
               << INDENT << "}" << endl;
         } else {
-            s << INDENT << QString("qtd_toUtf8(%1.utf16(), %1.size(), %2);").arg(qt_name, java_name) << endl;
+            s << INDENT << QString("_d_toUtf8(%1.utf16(), %1.size(), %2);").arg(qt_name, java_name) << endl;
         }
     } else if (java_type->isTargetLangChar()) {
         s << INDENT << "jchar " << java_name << " = " << qt_name << ".unicode();" << endl;
--- a/generator/cppimplgenerator.h	Thu Aug 20 19:08:32 2009 +0000
+++ b/generator/cppimplgenerator.h	Sat Aug 22 12:50:58 2009 +0000
@@ -212,7 +212,6 @@
     void writeQObjectLink(QTextStream &s, const AbstractMetaClass *java_class);
     void writeSignalHandler(QTextStream &s, const AbstractMetaClass *java_class, AbstractMetaFunction *signal);
     static void writeInitCallbacks(QTextStream &s, const AbstractMetaClass *java_class);
-    static void writeQtdEntityFunction(QTextStream &s, const AbstractMetaClass *java_class);
     void writeRefArguments(QTextStream &s, const AbstractMetaFunction *java_function);
 
 private:
--- a/generator/dgenerator.cpp	Thu Aug 20 19:08:32 2009 +0000
+++ b/generator/dgenerator.cpp	Sat Aug 22 12:50:58 2009 +0000
@@ -317,7 +317,7 @@
     }
 */
     // Generates Java 1.5 type enums
-    s << "public enum " << d_enum->enclosingClass()->name() << "_" << d_enum->name() << " {" << endl;
+    s << "    public enum " << d_enum->enclosingClass()->name() << "_" << d_enum->name() << " {" << endl;
     const AbstractMetaEnumValueList &values = d_enum->values();
     EnumTypeEntry *entry = d_enum->typeEntry();
 
@@ -477,11 +477,11 @@
 }
 
 static QString function_call_for_ownership(TypeSystem::Ownership owner)
-{  
+{
     if (owner == TypeSystem::CppOwnership) {
-        return "__setFlags(QtdObjectFlags.nativeOwnership, true)";
+        return "__set_native_ownership(true)";
     } else /* qtd 2 if (owner == TypeSystem::TargetLangOwnership) */ {
-        return "__setFlags(QtdObjectFlags.nativeOwnership, false)";
+        return "__set_native_ownership(false)";
     }/* else if (owner == TypeSystem::DefaultOwnership) {
         return "__no_real_delete = false";
 
@@ -696,21 +696,21 @@
     s << INDENT;
     if ( (has_return_type && d_function->argumentReplaced(0).isEmpty() ) || d_function->isConstructor()) { //qtd
         if(d_function->type() && d_function->type()->isQObject()) { // qtd
-            s << "void *ret = ";
+            s << "void *__qt_return_value = ";
         } else if(return_in_arg) // qtd
             ;
         else if (d_function->isConstructor()) { // qtd
-            s << "void* ret = ";
+            s << "void* __qt_return_value = ";
         } else if (return_type && return_type->isValue() && !return_type->typeEntry()->isStructInD()) {
-            s << "void* ret = ";
+            s << "void* __qt_return_value = ";
         } else if (return_type && return_type->isVariant()) {
-            s << "void* ret = ";
+            s << "void* __qt_return_value = ";
         } else if (return_type && ( return_type->isObject() ||
                   (return_type->isNativePointer() && return_type->typeEntry()->isValue()) ||
                    return_type->typeEntry()->isInterface()) ) {
-            s << "void* ret = ";
+            s << "void* __qt_return_value = ";
         } else if (return_type && return_type->isArray()) {
-            s << return_type->arrayElementType()->name() + "* ret = ";
+            s << return_type->arrayElementType()->name() + "* __qt_return_value = ";
         } else {
             returnImmediately = true;
             s << "return ";
@@ -765,9 +765,9 @@
 
     if (!d_function->isConstructor() && !d_function->isStatic()) {
         if(dVersion == 2 && d_function->isConstant())
-            s << "(cast(" << d_function->ownerClass()->name() << ")this).__nativeId";
+            s << "(cast(" << d_function->ownerClass()->name() << ")this).nativeId";
         else
-            s << "__nativeId";
+            s << "nativeId";
     }
 
     if (d_function->isConstructor() &&
@@ -801,7 +801,7 @@
             QString arg_name = arg->argumentName();
 
             if (type->isVariant())
-                s << arg_name << " is null ? null : " << arg_name << ".__nativeId";
+                s << arg_name << " is null ? null : " << arg_name << ".nativeId";
             else if (te->designatedInterface())
                 s << arg_name << " is null ? null : " << arg_name << ".__ptr_" << te->designatedInterface()->name();
             else if (modified_type == "string" /* && type->fullName() == "char" */) {
@@ -831,9 +831,9 @@
                 } // else if (value type is abstract) then we will get a null pointer exception, which is all right
 
                 if(dVersion == 2 && type->isConstant())
-                    s << "(cast(" << type->name() << ")" << arg_name << ").__nativeId";
+                    s << "(cast(" << type->name() << ")" << arg_name << ").nativeId";
                 else
-                    s << arg_name << ".__nativeId";
+                    s << arg_name << ".nativeId";
             }
         }
     }
@@ -864,14 +864,14 @@
 /* qtd2
     if (needs_return_variable) {
         if (owner != TypeSystem::InvalidOwnership) {
-            s << INDENT << "if (ret != null) {" << endl;
+            s << INDENT << "if (__qt_return_value != null) {" << endl;
             if (return_type->isContainer())
-                writeOwnershipForContainer(s, owner, return_type, "ret");
+                writeOwnershipForContainer(s, owner, return_type, "__qt_return_value");
             else
-                s << INDENT << "    ret." << function_call_for_ownership(owner) << ";" << endl;
+                s << INDENT << "    __qt_return_value." << function_call_for_ownership(owner) << ";" << endl;
             s << INDENT << "}" << endl;
         }
-        s << INDENT << "return ret;" << endl;
+        s << INDENT << "return __qt_return_value;" << endl;
     }
 */
     if (d_function->isConstructor()) {
@@ -893,31 +893,29 @@
         }
 
         if ( ( has_return_type && d_function->argumentReplaced(0).isEmpty() )) // qtd
-        {
             if(return_type->isQObject())
-                s << return_type->name() << ".getObject(ret);" << endl;
-        }
+                s << "qtd_" << return_type->name() << "_from_ptr(__qt_return_value);" << endl;
 
         if (return_type->isValue() && !return_type->typeEntry()->isStructInD())
-            s << "new " << return_type->name() << "(ret);" << endl;
+            s << "new " << return_type->name() << "(__qt_return_value, false);" << endl;
 
         if (return_type->isVariant())
-            s << "new QVariant(ret);" << endl;
+            s << "new QVariant(__qt_return_value, false);" << endl;
 
         if (return_type->isNativePointer() && return_type->typeEntry()->isValue())
-            s << "new " << return_type->name() << "(ret, QtdObjectFlags.nativeOwnership);" << endl;
+            s << "new " << return_type->name() << "(__qt_return_value, true);" << endl;
 
         if (return_type->isObject()) {
             if(d_function->storeResult())
-                s << INDENT << QString("__m_%1.__nativeId = ret;").arg(d_function->name()) << endl
+                s << INDENT << QString("__m_%1.nativeId = __qt_return_value;").arg(d_function->name()) << endl
                   << INDENT << QString("return __m_%1;").arg(d_function->name()) << endl;
             else
-                s << "qtd_" << return_type->name() << "_from_ptr(ret);" << endl;
+                s << "qtd_" << return_type->name() << "_from_ptr(__qt_return_value);" << endl;
             s << endl;
         }
 
         if (return_type->isArray()) {
-            s << "ret[0 .. " << return_type->arrayElementCount() << "];" << endl;
+            s << "__qt_return_value[0 .. " << return_type->arrayElementCount() << "];" << endl;
         }
 
         foreach (ReferenceCount referenceCount, referenceCounts) {
@@ -1682,32 +1680,60 @@
     if (!d_class->hasConstructors())
         return;
 
-    bool isTheQObject = d_class->name() == "QObject";
-    if (isTheQObject || !d_class->isQObject())
-    {
-        s << INDENT << "protected override void __deleteNative() {" << endl;
+    s << endl;
+    if (d_class->baseClassName().isEmpty()) {
+        s << INDENT << "~this() { " << endl;
         {
-            if (isTheQObject)
-                s << INDENT << "qtd_delete_qobject(__nativeId);" << endl;
-            else if (!d_class->isQObject())
-                s << INDENT << "qtd_" << d_class->name() << "_destructor(__nativeId);" << endl;
+            Indentation indent(INDENT);
+
+/*
+            if(d_class->name() == "QObject")
+                s << INDENT << "if(!__gc_managed)" << endl
+                        << INDENT << "    remove(__gc_ref_list, this);" << endl
+                        << INDENT << "if(!__no_real_delete && __gc_managed) {" << endl
+                        << INDENT << "    __qobject_is_deleting = true;" << endl
+                        << INDENT << "    scope(exit) __qobject_is_deleting = false;" << endl
+                        << INDENT << "    __free_native_resources();" << endl
+                        << INDENT << "}" << endl;
+*/
+            if(d_class->name() == "QObject")
+                s << INDENT << "if(!__no_real_delete) {" << endl
+                  << INDENT << "    __qobject_is_deleting = true;" << endl
+                  << INDENT << "    scope(exit) __qobject_is_deleting = false;" << endl
+                  << INDENT << "    __free_native_resources();" << endl
+                  << INDENT << "}" << endl;
+            else
+                s << INDENT << "if(!__no_real_delete)" << endl
+                  << INDENT << "    __free_native_resources();" << endl;
         }
         s << INDENT << "}" << endl << endl;
     }
+
+    s << INDENT << "protected void __free_native_resources() {" << endl;
+    {
+        Indentation indent(INDENT);
+        s << INDENT << "qtd_" << d_class->name() << "_destructor(nativeId());" << endl;
+    }
+    s << INDENT << "}" << endl << endl;
 }
 
-void DGenerator::writeFlagsSetter(QTextStream &s, const AbstractMetaClass *d_class)
+void DGenerator::writeOwnershipMethods(QTextStream &s, const AbstractMetaClass *d_class)
 {
+    s << INDENT << "void __set_native_ownership(bool ownership_)";
     if (d_class->isInterface() || d_class->isNamespace())
-        s << INDENT << "void __setFlags(QtdObjectFlags flags, bool val);";
-    else // COMPILER BUG:
-        s << INDENT << "void __setFlags(QtdObjectFlags flags, bool val) { super.__setFlags(flags, val); }";
+        s << ";";
+    else {
+        s << " {" << endl
+          << INDENT << "    __no_real_delete = ownership_;" << endl
+          << INDENT << "}" << endl << endl;
+    }
 }
 
 void DGenerator::writeSignalHandlers(QTextStream &s, const AbstractMetaClass *d_class)
 {
     AbstractMetaFunctionList signal_funcs = signalFunctions(d_class);
 
+    //TODO: linkage trivia should be abstracted away
     QString attr;
 
     s << "// signal handlers" << endl;
@@ -1763,7 +1789,8 @@
                     if(ctype->isAbstract())
                         type_name = type_name + "_ConcreteWrapper";
                     s << INDENT << "scope " << arg_name << " = new " << type_name
-                                << "(cast(void*)(" << arg_ptr << "), QtdObjectFlags.nativeOwnership);" << endl;
+                                << "(cast(void*)(" << arg_ptr << "), true);" << endl
+                                << INDENT << arg_name << ".__no_real_delete = true;";
                 }
                 s << endl;
             }
@@ -1789,20 +1816,6 @@
 
     bool fakeClass = d_class->attributes() & AbstractMetaAttributes::Fake;
 
-
-    QString auxModName = d_class->package() + "." + d_class->name() + "_aux";
-    FileOut auxFile(outputDirectory() + "/" + subDirectoryForClass(d_class) + "/" + d_class->name() + "_aux.d");
-    auxFile.isDone = true;
-    auxFile.stream << "module " << auxModName << ";" << endl << endl;
-
-    bool staticInit = d_class->isQObject() || (cpp_shared && d_class->generateShellClass() && !d_class->isInterface());
-    if (staticInit)
-    {
-        auxFile.isDone = false;
-        auxFile.stream << "extern(C) void static_init_" << d_class->name() << "();" << endl;
-        auxFile.stream << "static this() { static_init_" << d_class->name() << "; }" << endl << endl;
-    }
-
     if (m_docs_enabled) {
         m_doc_parser = new DocParser(m_doc_directory + "/" + d_class->name().toLower() + ".jdoc");
     }
@@ -1884,31 +1897,14 @@
         }
     }
 
-    // Enums aliases outside of the class - hack
-    if (!d_class->enums().isEmpty()) {
-        auxFile.isDone = false;
-        foreach (AbstractMetaEnum *d_enum, d_class->enums())
-            writeEnum(auxFile.stream, d_enum);
-    }
-
-    // Auxiliary file contents should have been written at this point
-    if (!auxFile.isDone)
-    {
-        s << "public import " << auxModName << ";" << endl;
-        auxFile.done();
-    }
-
     if (!m_isRecursive) {
         s << "public import qt.QGlobal;" << endl
           << "public import qt.core.Qt;" << endl
-          << "private import qt.QtdObject;" << endl
+          << "private import qt.QtDObject;" << endl
           << "private import qt.core.QString;" << endl
           << "private import qt.qtd.Array;" << endl;
         if (d_class->isQObject()) {
-            s << "public import qt.Signal;" << endl
-              << "public import qt.core.QMetaObject;" << endl
-              << "public import qt.qtd.Traits;" << endl;
-
+            s << "public import qt.Signal;" << endl;
             if (d_class->name() != "QObject")
                 s << "public import qt.core.QObject;" << endl;
         }
@@ -1928,6 +1924,9 @@
         if(d_class->isQObject())
             s << "private import " << d_class->package() << ".ArrayOps2;" << endl;
 
+        if (!d_class->enums().isEmpty())
+            s << "public import " << d_class->package() << "." << d_class->name() << "_enum;" << endl << endl;
+
         s << "// automatic imports-------------" << endl;
         writeRequiredImports(s, d_class);
         s << endl;
@@ -1936,23 +1935,35 @@
             s << "import std.stdio;" << endl
               << "import std.string;" << endl
               << "import std.utf;" << endl
-              << "import core.memory;" << endl;
+              << "import core.memory;";
         }
         else
         {
             s << "import tango.io.Stdout;" << endl
               << "import tango.stdc.stringz;" << endl
               << "import tango.text.convert.Utf;" << endl
-              << "import tango.core.Memory;" << endl;
+              << "import tango.core.Memory;";
         }
-
-        s << endl << endl;
+        s << endl << endl << endl;
     }
 
     if (m_doc_parser) {
         s << m_doc_parser->documentation(d_class) << endl << endl;
     }
 
+    // Enums aliases outside of the class - hack
+    if (!d_class->enums().isEmpty()) {
+        QString fileName = QString("%1_enum.d").arg(d_class->name());
+        FileOut fileOut(outputDirectory() + "/" + subDirectoryForClass(d_class) + "/" + fileName);
+
+        fileOut.stream << "module " << d_class->package() << "." << d_class->name() << "_enum;" << endl << endl;
+        foreach (AbstractMetaEnum *d_enum, d_class->enums())
+            writeEnum(fileOut.stream, d_enum);
+    }
+
+
+    s << endl;
+
 /* qtd    s << "@QtJambiGeneratedClass" << endl;
 
     if ((d_class->typeEntry()->typeFlags() & ComplexTypeEntry::Deprecated) != 0) {
@@ -2145,6 +2156,9 @@
     foreach (AbstractMetaEnum *d_enum, d_class->enums())
         writeEnumAlias(s, d_enum);
 
+    if (!d_class->enums().isEmpty() && !d_class->functions().isEmpty())
+        s << endl;
+
     // Signals
     AbstractMetaFunctionList signal_funcs;
 
@@ -2237,39 +2251,37 @@
           << INDENT << "private native boolean __qt_signalInitialization(long ptr, String name);" << endl;
     }
 */
-    if (d_class->isQObject())
-        writeQObjectFunctions(s, d_class);
-
     // Add dummy constructor for use when constructing subclasses
     if (!d_class->isNamespace() && !d_class->isInterface() && !fakeClass) {
         s << endl
           << INDENT << "public "
           << "this";
 
-
-        Indentation indent(INDENT);
-
-        s << "(void* native_id, QtdObjectFlags flags = QtdObjectFlags.none) {" << endl
-          << INDENT << "super(native_id, flags);" << endl;
-
-        if (d_class->name() == "QObject")
+        if(d_class->name() == "QObject")
         {
-            // To prevent GC from collecting the object, add it to the statically rooted linked list
-            s << INDENT << "    __next = __root;" << endl
-            << INDENT << "    __root = this;" << endl
-            << INDENT << "    if (__next) {" << endl
-            << INDENT << "        __next.__prev = this;" << endl
-            << INDENT << "    }" << endl << endl;
+            {
+                Indentation indent(INDENT);
+                s << "(void* native_id, bool gc_managed) {" << endl
+/*                  << INDENT << "if(!gc_managed)" << endl
+                  << INDENT << "    __gc_ref_list ~= this;" << endl
+                  << INDENT << "__gc_managed = gc_managed;" << endl */
+                  << INDENT << "super(native_id);" << endl;
+            }
         }
-
-        /*
+        else {
+            Indentation indent(INDENT);
+            if(d_class->isQObject())
+                s << "(void* native_id, bool gc_managed) {" << endl
+                  << INDENT << "super(native_id, gc_managed);" << endl;
+            else
+                s << "(void* native_id, bool no_real_delete = false) {" << endl
+                  << INDENT << "super(native_id, no_real_delete);" << endl;
+        }
         if (cpp_shared) {
             if (d_class->generateShellClass() && !d_class->isInterface())
-                s << INDENT << "if (!static_inited)" << endl
+                s << INDENT << "if (!init_flag_" << d_class->name() << ")" << endl
                   << INDENT << "    static_init_" << d_class->name() << "();" << endl << endl;
         }
-        */
-
         // customized store-result instances
         d_funcs = d_class->functionsInTargetLang();
         for (int i=0; i<d_funcs.size(); ++i) {
@@ -2292,7 +2304,7 @@
                 s << INDENT << "    __m_" << d_function->name() << " = new "
                         << type_name << "(cast(void*)null);" << endl;
                 if (d_function->type()->isQObject())
-                    s << INDENT << "    __m_" << d_function->name() << ".__setFlags(QtdObjectFlags.nativeOwnership, true);" << endl;
+                    s << INDENT << "    __m_" << d_function->name() << ".__no_real_delete = true;" << endl;
             }
         }
 
@@ -2304,14 +2316,14 @@
                 AbstractMetaClass *iface = interfaces.at(i);
 
                 s << INDENT << "    __m_ptr_" << iface->name() << " = qtd_" << d_class->name() << "_cast_to_" << iface->qualifiedCppName()
-                  << "(__nativeId);" << endl;
+                  << "(nativeId);" << endl;
             }
         }
 
 
         s << INDENT << "}" << endl << endl;
 
-/******************!!!DUPLICATE OF ABOVE!!!*********************/
+/******************!!!DUBLICATE OF ABOVE!!!*********************/
         for (int i=0; i<d_funcs.size(); ++i) {
             AbstractMetaFunction *d_function = d_funcs.at(i);
             uint included_attributes = 0;
@@ -2375,7 +2387,7 @@
 
 /* qtd    writeJavaLangObjectOverrideFunctions(s, d_class);
 */
-    writeFlagsSetter(s, d_class);
+    writeOwnershipMethods(s, d_class);
     s << "// Injected code in class" << endl;
     writeExtraFunctions(s, d_class);
 // qtd2    writeToStringFunction(s, d_class);
@@ -2416,10 +2428,13 @@
 
         {
             Indentation indent(INDENT);
-            s << INDENT << "public this(void* native_id, QtdObjectFlags flags = QtdObjectFlags.nativeOwnership) {" << endl
-              << INDENT << "    super(native_id, flags);" << endl << endl;
-            
-            /******************!!!DUPLICATE!!!*********************/
+            s << INDENT << "public this(void* native_id, bool no_real_delete = true) {" << endl
+              << INDENT << "    super(native_id, no_real_delete);" << endl;
+
+
+
+
+            /******************!!!DUBLICATE!!!*********************/
             d_funcs = d_class->functionsInTargetLang();
             for (int i=0; i<d_funcs.size(); ++i) {
                 AbstractMetaFunction *d_function = d_funcs.at(i);
@@ -2437,7 +2452,7 @@
                     s << INDENT << "    __m_" << d_function->name() << " = new "
                             << type_name << "(cast(void*)null);" << endl;
                     if (d_function->type()->isQObject())
-                        s << INDENT << "    __m_" << d_function->name() << ".__setFlags(QtdObjectFlags.nativeOwnership, true);" << endl;
+                        s << INDENT << "    __m_" << d_function->name() << ".__no_real_delete = true;" << endl;
                 }
             }
 
@@ -2494,15 +2509,18 @@
 
     if (d_class->generateShellClass()) { // qtd2
         if (d_class->hasVirtualFunctions()
-            && (d_class->typeEntry()->isObject() && !d_class->typeEntry()->isQObject()) )
+            && (d_class->typeEntry()->isObject() || d_class->typeEntry()->isQObject()) )
         s << endl << "extern (C) void *__" << d_class->name() << "_entity(void *q_ptr);" << endl << endl;
     }
 
+    if (d_class->isQObject())
+        writeQObjectFunctions(s, d_class);
+
 
 //    if (d_class->needsConversionFunc)
         writeConversionFunction(s, d_class);
 
-    if (d_class->hasConstructors() && !d_class->isQObject())
+    if (d_class->hasConstructors())
         s << "extern (C) void qtd_" << d_class->name() << "_destructor(void *ptr);" << endl << endl;
 
     // qtd
@@ -2546,29 +2564,22 @@
             writeShellVirtualFunction(s, function, d_class, pos);
     }
 
-    // write static constructor
-    if (staticInit) {
-        QString initArgs;
-        if (cpp_shared)
-        {
-            initArgs = "void* virtuals";
+    //init callbacks from dll to D side
+    if (cpp_shared) {
+        bool shellClass = d_class->generateShellClass();
+        if (shellClass && !d_class->isInterface()) {
+            QString initArgs = "void* virtuals";
             if (d_class->isQObject())
-                initArgs += ", void* signals";
+                initArgs += ", void* signals, void* qobj_del";
 
             s << "private extern (C) void qtd_" << d_class->name()
-            << QString("_initCallBacks(%1);").arg(initArgs) << endl << endl;
-        }
-
-        s << "extern(C) void static_init_" << d_class->name() << "() {" << endl;
-
-        if (d_class->isQObject()) {
-            s << INDENT << "if (!" << d_class->name() << "._staticMetaObject) " << endl
-            << INDENT << "    " << d_class->name() << ".createStaticMetaObject;" << endl << endl;
-        }
-
-        if (cpp_shared) {
-             // virtual functions
-            s << INDENT << "void*[" << virtualFunctions.size() << "] virt_arr;" << endl;
+              << QString("_initCallBacks(%1);").arg(initArgs) << endl << endl
+              << "private bool init_flag_" << d_class->name() << " = false;" << endl
+              << "void static_init_" << d_class->name() << "() {" << endl
+              << INDENT << "init_flag_" << d_class->name() << " = true;" << endl << endl
+
+              // virtual functions
+              << INDENT << "void*[" << virtualFunctions.size() << "] virt_arr;" << endl;
             for (int pos = 0; pos<virtualFunctions.size(); ++pos) {
                 const AbstractMetaFunction *function = virtualFunctions.at(pos);
                 if (!notWrappedYet(function)) // qtd2
@@ -2579,9 +2590,8 @@
             else
                 initArgs = "virt_arr.ptr";
 
+            // signals
             if (d_class->isQObject()) {
-
-                // signals
                 AbstractMetaFunctionList signal_funcs = signalFunctions(d_class);
                 s << endl << INDENT << "void*[" << signal_funcs.size() << "] sign_arr;" << endl;
                 for(int i = 0; i < signal_funcs.size(); i++) {
@@ -2592,12 +2602,16 @@
                     initArgs += ", null";
                 else
                     initArgs += ", sign_arr.ptr";
+
+                // QObject_delete
+                s << endl << INDENT << "void *qobj_del;" << endl
+                  << INDENT << "qobj_del = &qtd_D_" << d_class->name() << "_delete;" << endl;
+                initArgs += ", qobj_del";
             }
 
-            s << INDENT << "qtd_" << d_class->name() << QString("_initCallBacks(%1);").arg(initArgs) << endl;
+            s << INDENT << "qtd_" << d_class->name() << QString("_initCallBacks(%1);").arg(initArgs) << endl
+              << "}" << endl << endl;
         }
-
-        s << "}" << endl << endl;
     }
 
     writeSignalHandlers(s, d_class);
@@ -2614,43 +2628,56 @@
         write(s, cls);
         m_isRecursive = false;
     }
-
-    // qtd static metaobject
-    if (d_class->isQObject())
-        s << "private extern(C) void* qtd_" << d_class->name() << "_staticMetaObject();";
 }
 
 void DGenerator::writeConversionFunction(QTextStream &s, const AbstractMetaClass *d_class)
 {
     const ComplexTypeEntry *ctype = d_class->typeEntry();
-    if(ctype->isQObject() || !ctype->isObject())
+    if(!ctype->isQObject() && !ctype->isObject())
         return;
     QString class_name = ctype->name();
     QString return_type_name = class_name;
     if(ctype->designatedInterface())
         return_type_name = ctype->designatedInterface()->name();
-
-    s << return_type_name << " qtd_" << class_name << "_from_ptr(void* ret) {" << endl;
-
-
-    QString type_name = class_name;
-    if(ctype->isAbstract())
-        type_name = ctype->targetLangName() + "_ConcreteWrapper";
-
-    // if class has virtual functions then it has classname_entity function so
-    // we can look for D Object pointer. otherwise create new wrapper
-    if (d_class->hasVirtualFunctions()) {
-        s << INDENT << "void* d_obj = __" << ctype->targetLangName() << "_entity(ret);" << endl
-          << INDENT << "if (d_obj !is null) {" << endl
-          << INDENT << "    auto d_obj_ref = cast (Object) d_obj;" << endl
-          << INDENT << "    return cast(" << return_type_name << ") d_obj_ref;" << endl
-          << INDENT << "} else {" << endl
-          << INDENT << "    auto return_value = new " << type_name << "(ret, QtdObjectFlags.nativeOwnership);" << endl
-          << INDENT << "    return return_value;" << endl
-          << INDENT << "}" << endl;
-    } else {
-        s << INDENT << "auto return_value = new " << type_name << "(ret, QtdObjectFlags.nativeOwnership);" << endl
-          << INDENT << "return return_value;" << endl;
+    s << return_type_name << " qtd_" << class_name << "_from_ptr(void* __qt_return_value) {" << endl;
+
+    if(ctype->isQObject()) {
+        QString type_name = class_name;
+        if(ctype->isAbstract())
+            type_name = type_name + "_ConcreteWrapper";
+
+        s << INDENT << "if (__qt_return_value is null)" << endl
+          << INDENT << "    return null;" << endl
+          << INDENT << "void* d_obj = qtd_" << class_name << "_d_pointer(__qt_return_value);" << endl
+          << INDENT << "if (d_obj is null) {" << endl
+          << INDENT << "    auto new_obj = new " << type_name << "(__qt_return_value, false);" << endl
+          << INDENT << "    qtd_" << class_name << "_create_link(new_obj.nativeId, cast(void*) new_obj);" << endl
+          << INDENT << "    new_obj.__no_real_delete = true;" << endl
+          << INDENT << "    return new_obj;" << endl
+          << INDENT << "} else" << endl
+          << INDENT << "    return cast(" << class_name << ") d_obj;" << endl;
+    } else if (ctype->isObject()) {
+        QString type_name = class_name;
+        if(ctype->isAbstract())
+            type_name = ctype->targetLangName() + "_ConcreteWrapper";
+
+        // if class has virtual functions then it has classname_entity function so
+        // we can look for D Object pointer. otherwise create new wrapper
+        if (d_class->hasVirtualFunctions()) {
+            s << INDENT << "void* d_obj = __" << ctype->targetLangName() << "_entity(__qt_return_value);" << endl
+              << INDENT << "if (d_obj !is null) {" << endl
+              << INDENT << "    auto d_obj_ref = cast (Object) d_obj;" << endl
+              << INDENT << "    return cast(" << return_type_name << ") d_obj_ref;" << endl
+              << INDENT << "} else {" << endl
+              << INDENT << "    auto return_value = new " << type_name << "(__qt_return_value, true);" << endl
+              << INDENT << "    return_value.__no_real_delete = true;" << endl
+              << INDENT << "    return return_value;" << endl
+              << INDENT << "}" << endl;
+        } else {
+            s << INDENT << "auto return_value = new " << type_name << "(__qt_return_value, true);" << endl
+              << INDENT << "return_value.__no_real_delete = true;" << endl
+              << INDENT << "return return_value;" << endl;
+        }
     }
     s << "}" << endl << endl;
 }
@@ -2658,36 +2685,14 @@
 
 void DGenerator::writeQObjectFunctions(QTextStream &s, const AbstractMetaClass *d_class)
 {
-    QString concreteArg;
-    if (d_class->isAbstract())
-        concreteArg += ", " + d_class->name() + "_ConcreteWrapper";
-
-    s << "    private static QMetaObject _staticMetaObject;" << endl
-    << "    protected static void createStaticMetaObject() {" << endl
-    << "        assert(!_staticMetaObject);" << endl
-    << "        QMetaObject base;" << endl
-
-    << "        static if (!is(typeof(this) == QObject)) {" << endl
-    << "            alias BaseTypeTuple!(typeof(this))[0] B;" << endl
-    << "            if (!B._staticMetaObject)" << endl
-    << "                B.createStaticMetaObject;" << endl
-    << "            base = B._staticMetaObject;" << endl
-    << "        }"                                      << endl
-    << "        _staticMetaObject = new QMetaObject(qtd_" << d_class->name() << "_staticMetaObject, base);"   << endl
-    << "        _staticMetaObject.construct!(" << d_class->name() << concreteArg << ");" << endl
-    << "    }" << endl << endl
-
-    << "    QMetaObject metaObject() {" << endl
-    << "        return _staticMetaObject;" << endl
-    << "    }" << endl << endl
-
-    << "    static QMetaObject staticMetaObject() {" << endl
-    << "        return _staticMetaObject;" << endl
-    << "    }" << endl << endl
-
-    << "    static " << d_class->name() << " getObject(void* nativeId) {" << endl
-    << "        return static_cast!(" << d_class->name() << ")(_staticMetaObject.getObject(nativeId));" << endl
-    << "    }" << endl << endl;
+    s << "extern(C) void* qtd_" << d_class->name() << "_d_pointer(void *obj);" << endl
+      << "extern(C) void qtd_" << d_class->name() << "_create_link(void *obj, void* d_obj);" << endl << endl;
+    s << "private extern (C) void qtd_D_" << d_class->name() << "_delete(void *d_ptr) {" << endl
+      << "    auto d_ref = cast(QObject) d_ptr;" << endl
+      << "    d_ref.__no_real_delete = true;" << endl
+      << "    if(!d_ref.__qobject_is_deleting)"
+      << "        delete d_ref;" << endl
+      << "}" << endl << endl;
 }
 
 /*
@@ -2700,18 +2705,16 @@
 {
     if(ctype->isQObject()) {
         QString type_name = ctype->name();
-        if (ctype->isAbstract())
-            type_name += "_ConcreteWrapper";
-        s << "return " << type_name << ".getObject(ret);" << endl;
+        s << "return qtd_" << type_name << "_from_ptr(__qt_return_value);" << endl;
     } else if (ctype->isValue() && !ctype->isStructInD()) {
-        s << INDENT << "return new " << ctype->name() << "(ret);" << endl;
+        s << INDENT << "return new " << ctype->name() << "(__qt_return_value, false);" << endl;
     } else if (ctype->isVariant()) {
-        s << INDENT << "return new QVariant(ret);" << endl;
+        s << INDENT << "return new QVariant(__qt_return_value, false);" << endl;
     } else if (ctype->name() == "QModelIndex" || ctype->isStructInD()) {
-        s << INDENT << "return ret;" << endl;
+        s << INDENT << "return __qt_return_value;" << endl;
     } else if (ctype->isObject()) {
         QString type_name = ctype->name();
-        s << "return qtd_" << type_name << "_from_ptr(ret);" << endl;
+        s << "return qtd_" << type_name << "_from_ptr(__qt_return_value);" << endl;
     }
 }
 
@@ -2776,7 +2779,7 @@
     {
         Indentation indent(INDENT);
         s << INDENT << "if (signalId < __slotConnectors.length) {" << endl;
-        s << INDENT << "    __slotConnectors[signalId](__nativeId);" << endl;
+        s << INDENT << "    __slotConnectors[signalId](nativeId);" << endl;
         s << INDENT << "}" << endl;
     }
     s << INDENT << "}" << endl;
@@ -2785,7 +2788,7 @@
     {
         Indentation indent(INDENT);
         s << INDENT << "if (signalId < __slotDisconnectors.length) {" << endl;
-        s << INDENT << "    __slotDisconnectors[signalId](__nativeId);" << endl;
+        s << INDENT << "    __slotDisconnectors[signalId](nativeId);" << endl;
         s << INDENT << "}" << endl;
     }
     s << INDENT << "}" << endl;
@@ -2851,7 +2854,7 @@
                     s << INDENT << "auto " << arg_name << "_d_qstr = QString(" << arg_name << ", true);" << endl
                       << INDENT << "string " << arg_name << "_d_ref = " << arg_name << "_d_qstr.toNativeString();";
                 } else if(type->isVariant())
-                    s << INDENT << "scope " << arg_name << "_d_ref = new QVariant(" << arg_name << ", QtdObjectFlags.nativeOwnership);";
+                    s << INDENT << "scope " << arg_name << "_d_ref = new QVariant(" << arg_name << ", true);";
                 else if (type->typeEntry()->isStructInD())
                     continue;
                 else if (!type->hasNativeId() && !(type->typeEntry()->isValue() && type->isNativePointer()))
@@ -2863,7 +2866,7 @@
                     const ComplexTypeEntry *ctype = static_cast<const ComplexTypeEntry *>(type->typeEntry());
                     if(ctype->isAbstract())
                         type_name = type_name + "_ConcreteWrapper";
-                    s << INDENT << "scope " << arg_name << "_d_ref = new " << type_name << "(" << arg_name << ", QtdObjectFlags.nativeOwnership);";
+                    s << INDENT << "scope " << arg_name << "_d_ref = new " << type_name << "(" << arg_name << ", true);";
                 }
                 else if (type->isQObject()) {
                     QString type_name = type->name();
@@ -2871,7 +2874,13 @@
                     if(ctype->isAbstract())
                         type_name = type_name + "_ConcreteWrapper";
 
-                    s << INDENT << "scope " << arg_name << "_d_ref = new " << type_name << "(" << arg_name << ", QtdObjectFlags.nativeOwnership);" << endl;
+                    s << INDENT << "scope " << arg_name << "_so = new StackObject!(" << type_name << ");" << endl
+                      << INDENT << "auto " << arg_name << "_d_ref = " << arg_name << "_so(" << arg_name <<", true);" << endl
+                      << INDENT << arg_name << "_d_ref.__no_real_delete = true;";
+/*
+                    s << INDENT << "scope " << arg_name << "_d_ref = new " << type_name << "(" << arg_name <<", true);" << endl
+                      << INDENT << arg_name << "_d_ref.__no_real_delete = true;";
+*/
                 }
                 s << endl;
             }
@@ -2950,7 +2959,7 @@
         if(f_type) {
             if(f_type->isObject() || f_type->isQObject() || f_type->isVariant() ||
                (f_type->isValue() && !f_type->typeEntry()->isStructInD())) {
-                QString native_id = "__nativeId";
+                QString native_id = "nativeId";
                 if (f_type->typeEntry()->designatedInterface())
                     native_id =  "__ptr_" + f_type->typeEntry()->designatedInterface()->name();
                 s << INDENT << "return ret_value is null? null : ret_value." << native_id << ";" << endl;
@@ -3246,7 +3255,34 @@
             }
         }
 
-        s << INDENT << "this(ret);" << endl;
+        if(d_function->implementingClass()->isQObject())
+        {
+            bool hasParentArg = false;
+            AbstractMetaArgumentList arguments = d_function->arguments();
+            int arg_index = 0;
+            for (int i=0; i<arguments.count(); ++i) {
+                const AbstractMetaArgument *arg = arguments.at(i);
+                if (arg->argumentName().contains("parent", Qt::CaseInsensitive)) {
+                    arg_index = i;
+                    hasParentArg = true;
+                }
+            }
+
+            const AbstractMetaArgument *arg = arguments.at(arg_index);
+//            QString ctor_call = d_function->implementingClass()->name() == "QObject"? "this" : "super";
+            QString ctor_call = "this";
+            if (hasParentArg) {
+                s << INDENT << "bool gc_managed = " << arg->argumentName() << " is null ? true : false;" << endl
+                  << INDENT << ctor_call << "(__qt_return_value, gc_managed);" << endl;
+            } else {
+                s << INDENT << ctor_call << "(__qt_return_value, true);" << endl;
+            }
+
+            // creating a link object associated with the current QObject for signal handling and metadata
+            s << INDENT << "qtd_" << d_function->ownerClass()->name() << "_create_link(this.nativeId, cast(void*) this);" << endl;
+        }
+        else
+            s << INDENT << "this(__qt_return_value);" << endl;
     }
     s << INDENT << "}" << endl << endl;
 
@@ -3317,7 +3353,7 @@
             s << endl
               << "    @Override" << endl
               << "    public String toString() {" << endl
-              << "        if (__nativeId == 0)" << endl
+              << "        if (nativeId() == 0)" << endl
               << "            throw new QNoNativeResourcesException(\"Function call on incomplete object of type: \" +getClass().getName());" << endl
               << "        return __qt_toString(nativeId());" << endl
               << "    }" << endl
--- a/generator/dgenerator.h	Thu Aug 20 19:08:32 2009 +0000
+++ b/generator/dgenerator.h	Sat Aug 22 12:50:58 2009 +0000
@@ -151,7 +151,7 @@
     const TypeEntry* fixedTypeEntry(const TypeEntry *type);
 
     void writeDestructor(QTextStream &s, const AbstractMetaClass *d_class);
-    void writeFlagsSetter(QTextStream &s, const AbstractMetaClass *d_class);
+    void writeOwnershipMethods(QTextStream &s, const AbstractMetaClass *d_class);
     void writeSignalHandlers(QTextStream &s, const AbstractMetaClass *d_class);
     void writeEnumAlias(QTextStream &s, const AbstractMetaEnum *d_enum);
     void writeSignalConnectors(QTextStream &s, const AbstractMetaClass *d_class, AbstractMetaFunctionList signal_funcs);
--- a/generator/fileout.h	Thu Aug 20 19:08:32 2009 +0000
+++ b/generator/fileout.h	Sat Aug 22 12:50:58 2009 +0000
@@ -71,6 +71,7 @@
     static bool dummy;
     static bool diff;
 
+ private:
     bool isDone;
 };
 
--- a/generator/typesystem_core-java.java	Thu Aug 20 19:08:32 2009 +0000
+++ b/generator/typesystem_core-java.java	Sat Aug 22 12:50:58 2009 +0000
@@ -22,7 +22,7 @@
 * exception, Nokia gives you certain additional rights. These rights
 * are described in the Nokia Qt GPL Exception version 1.2, included in
 * the file GPL_EXCEPTION.txt in this package.
-*
+* 
 * Qt for Windows(R) Licensees
 * As a special exception, Nokia, as the sole copyright holder for Qt
 * Designer, grants users of the Qt/Eclipse Integration plug-in the
@@ -46,9 +46,10 @@
 
 class QObject___ extends QObject {
     
-    /* TODO: test whether the linked list is really a better solution
     public bool __stackAllocated = false;
     
+    public bool __qobject_is_deleting = false;
+    
     new(size_t size, void* p = null)
     {
         if (!p)
@@ -71,64 +72,12 @@
             }
         }
     }
-    */
     
-    private
-    {
-        static QObject __root;
-        QObject __next;
-        QObject __prev;
-    }
+    // list of QObjects references to prevent them from garbage collecting if they are managed by Qt
+    private static QObject[] __gc_ref_list;
     
-    ~this()
-    {
-        if (__prev)
-            __prev.__next = __next;
-        else
-            __root = __next;
-        
-        if (__next)      
-            __next.__prev = __prev;        
-    }
-    
-    /**
-    */
-    T findChild(T : QObject = QObject)(string name = null)
-    {
-        foreach (obj; children)
-        {
-            auto tmp = cast(T)obj;
-            if (tmp && (!name.length || tmp.objectName == name))
-                return tmp;
-            
-            tmp = obj.findChild!(T)(name);
-            if (tmp)
-                return tmp;
-        }
-        
-        return null;
-    }
-    
-    /**
-    */
-    T[] findChildren(T : QObject = QObject)(string name = null)
-    {
-        T[] result;
-        
-        void find(QObject[] objects)
-        {        
-            foreach (obj; objects)
-            {
-                auto tmp = cast(T)obj;
-                if (tmp && (!name.length || tmp.objectName == name))
-                    result ~= tmp;
-                find(obj.children);
-            }
-        }
-        
-        find(children);
-        return result;
-    }
+    // this flag needs to be set false when QObject is deleted from inside Qt so when deleting it from D it won't delete C++ object
+    public bool __no_real_delete = false;
 }// class
 
 abstract class QAbstractItemModel___ extends QAbstractItemModel {
@@ -192,14 +141,14 @@
 	{
 //        if (m_instance != null)
 //            throw new RuntimeException("QCoreApplication can only be initialized once");
-
+            
 		argc = args.length;
 		argv = toStringzArray(args);
 		this(&argc, argv);
 
 //        m_instance.aboutToQuit.connect(m_instance, "disposeOfMyself()");
 	}
-
+	
 	private int argc;
 	private char **argv;
 /*
@@ -540,7 +489,7 @@
 
     public final long write(string str) {
 	return write(str.ptr, str.length);
-    }
+    } 
 }// class
 
 class QCryptographicHash___ extends QCryptographicHash {
--- a/generator/typesystem_core-java.xml	Thu Aug 20 19:08:32 2009 +0000
+++ b/generator/typesystem_core-java.xml	Sat Aug 22 12:50:58 2009 +0000
@@ -1,5 +1,5 @@
 <?xml version="1.0"?>
-<typesystem package="qt.core" default-superclass="QtdObject">
+<typesystem package="qt.core" default-superclass="QtDObject">
     <inject-code>
     qt.Utilities.loadQtLibrary("QtCore");
     </inject-code>
--- a/generator/typesystem_core.xml	Thu Aug 20 19:08:32 2009 +0000
+++ b/generator/typesystem_core.xml	Sat Aug 22 12:50:58 2009 +0000
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<typesystem package="qt.core" default-superclass="QtdObject">
+<typesystem package="qt.core" default-superclass="QtDObject">
 <inject-code>
     qt.Utilities.loadQtLibrary("QtCore");
     </inject-code>
@@ -787,7 +787,7 @@
     </modify-function>
 
     <modify-function signature="setYMD(int, int, int)" remove="all"/> <!--### Obsolete in 4.3-->
-
+  
         <inject-code>
             <import-file name="typesystem_core-java.java" quote-after-line="class QDate___" quote-before-line="}// class"/>
         </inject-code>
@@ -814,7 +814,7 @@
     <modify-function signature="operator=(QDir)" remove="all"/>
     <modify-function signature="operator=(QString)" remove="all"/>
     <modify-function signature="addResourceSearchPath(QString)" remove="all"/> <!--### Obsolete in 4.3-->
-
+  
         <inject-code>
             <import-file name="typesystem_core-java.java" quote-after-line="class QDir___" quote-before-line="}// class"/>
         </inject-code>
@@ -882,7 +882,7 @@
     <modify-function signature="operator-=(QSize)"> <access modifier="private"/> </modify-function>
     <modify-function signature="rheight()"> <remove/> </modify-function>
     <modify-function signature="rwidth()"> <remove/> </modify-function>
-
+  
         <inject-code>
             <insert-template name="core.multiply-devide-add-subtract">
                 <replace from="%TYPE" to="QSize"/>
@@ -897,7 +897,7 @@
     <modify-function signature="operator-=(QSizeF)"> <access modifier="private"/> </modify-function>
     <modify-function signature="rheight()"> <remove/> </modify-function>
     <modify-function signature="rwidth()"> <remove/> </modify-function>
-
+  
         <inject-code>
             <insert-template name="core.multiply-devide-add-subtract">
                 <replace from="%TYPE" to="QSizeF"/>
@@ -1067,7 +1067,7 @@
     <modify-function signature="operator^=(QBitArray)" access="private"/>
     <modify-function signature="operator|=(QBitArray)" access="private"/>
     <modify-function signature="operator~()const" access="private"/>
-
+  
       <inject-code>
           <import-file name="typesystem_core-java.java" quote-after-line="class QBitArray___" quote-before-line="}// class"/>
       </inject-code>
@@ -1091,7 +1091,7 @@
 
     <modify-function signature="modelAboutToBeReset()" private-signal="yes"/>
     <modify-function signature="modelReset()" private-signal="yes"/>
-
+    
         <modify-function signature="parent()const" remove="java"/>
         <extra-includes>
             <include file-name="QStringList" location="global"/>
@@ -1194,13 +1194,13 @@
   <interface-type name="QFactoryInterface" java-name="QAbstractFactory"/>
 
   <value-type name="QByteArray">
-
+    
     <modify-function signature="at(int)const">
         <modify-argument index="return">
             <replace-type modified-type="ubyte"/>
         </modify-argument>
     </modify-function>
-
+    
     <extra-includes>
         <include file-name="QNoImplicitBoolCast" location="global"/>
     </extra-includes>
@@ -1738,7 +1738,7 @@
     <modify-function signature="readLink(QString)" remove="all"/> <!--### Obsolete in 4.3-->
     <modify-function signature="map(long long,long long,QFile::MemoryMapFlags)" remove="all"/> <!-- Can't provide same API and performance -->
     <modify-function signature="unmap(unsigned char*)" remove="all"/> <!-- Can't provide same API and performance -->
-
+  
         <inject-code>
             <import-file name="typesystem_core-java.java" quote-after-line="class QFile___" quote-before-line="}// class"/>
         </inject-code>
@@ -1759,11 +1759,11 @@
             <access modifier="private"/>
             <rename to="getByte"/>
         </modify-function>
-
+	
 	<modify-function signature="write(const char*)">
             <access modifier="private"/>
         </modify-function>
-
+	
 	<modify-function signature="write(const char*,long long)">
             <access modifier="private"/>
         </modify-function>
@@ -2025,7 +2025,7 @@
     <modify-function signature="toUnicode(const char*)const">
         <remove/>
     </modify-function>
-
+  
         <inject-code>
             <import-file name="typesystem_core-java.java" quote-after-line="class QTextCodec___" quote-before-line="}// class"/>
         </inject-code>
@@ -2116,7 +2116,7 @@
     <modify-function signature="translate(const char*,const char*,const char*,int)const">
         <remove/>
     </modify-function>
-
+  
         <extra-includes>
             <include file-name="QTextCodec" location="global"/>
          </extra-includes>
@@ -2200,7 +2200,7 @@
     <modify-function signature="buffer()const">
         <remove/>
     </modify-function>
-
+  
 
         <inject-code>
             <import-file name="typesystem_core-java.java" quote-after-line="class QBuffer___" quote-before-line="}// class"/>
@@ -2269,7 +2269,7 @@
     </extra-includes>
     <modify-function signature="map(long long,long long,QFile::MemoryMapFlags)" remove="all"/>
     <modify-function signature="unmap(unsigned char*)" remove="all"/>
-
+  
     <inject-code>
         <import-file name="typesystem_core-java.java" quote-after-line="class QAbstractFileEngine___" quote-before-line="}// class"/>
     </inject-code>
@@ -2316,7 +2316,7 @@
     <modify-function signature="mapping(QWidget*)const" remove="all"/>
 
     <modify-function signature="setMapping(QObject*,QWidget*)" remove="all"/>
-
+  
         <inject-code>
             <import-file name="typesystem_core-java.java" quote-after-line="class QSignalMapper___" quote-before-line="}// class"/>
         </inject-code>
@@ -2361,59 +2361,6 @@
   </object-type>
 
   <object-type name="QObject">
-	<inject-code class="native">
-
-#ifdef CPP_SHARED
-QTD_EXPORT_VAR(qtd_delete_d_qobject);
-
-extern "C" DLL_PUBLIC void qtd_QObjectEntity_initCallBacks(pfunc_abstr del_d_qobj)
-{
-	QTD_EXPORT_VAR_SET(qtd_delete_d_qobject, del_d_qobj);
-}
-#endif
-
-
-extern "C" DLL_PUBLIC void* qtd_get_d_qobject(void *nativeId)
-{
-    QtD_QObjectEntity *entity = QtD_QObjectEntity::getQObjectEntity((QObject*)nativeId);
-    return entity ? entity-&gt;dId : NULL;
-}
-
-extern "C" DLL_PUBLIC void qtd_delete_qobject(void *nativeId)
-{
-    delete (QObject*)nativeId;
-}
-
-extern "C" DLL_PUBLIC void qtd_create_qobject_entity(void* nativeId, void *dId)
-{
-	new QtD_QObjectEntity((QObject*)nativeId, dId);
-}
-
-extern "C" DLL_PUBLIC void* qtd_QObject_metaObject(void* nativeId)
-{
-    return (void*)((QObject*)nativeId)->metaObject();
-}
-	</inject-code>
-
-	<inject-code class="java-free">
-extern(C) void* qtd_get_d_qobject(void* nativeId);
-extern(C) void qtd_delete_qobject(void* nativeId);
-extern(C) void* qtd_create_qobject_entity(void* nativeId, void* dId);
-extern(C) void* qtd_QObject_metaObject(void* nativeId);
-
-extern(C) void qtd_delete_d_qobject(void* dId)
-{
-    auto obj = cast(QObject)dId;
-	
-	if (!(obj.__flags &amp; QtdObjectFlags.dOwnership))
-	{
-		// Avoid deleting native object twice
-		obj.__setFlags(QtdObjectFlags.nativeOwnership, true);
-		delete obj;
-	}
-}
-	</inject-code>
-
     <modify-function signature="childEvent(QChildEvent*)">
         <modify-argument index="1" invalidate-after-use="yes"/>
     </modify-function>
@@ -2454,7 +2401,6 @@
                 __gc_managed = false;
             }
         </inject-code> -->
-
     </modify-function>
 
     <modify-function signature="deleteLater()">
@@ -2478,9 +2424,11 @@
         <include file-name="QVarLengthArray" location="global"/>
     </extra-includes>
 
-	<inject-code class="java">
-	  <import-file name="typesystem_core-java.java" quote-after-line="class QObject___" quote-before-line="}// class"/>
-	</inject-code>
+
+
+      <inject-code class="java">
+          <import-file name="typesystem_core-java.java" quote-after-line="class QObject___" quote-before-line="}// class"/>
+      </inject-code>
   </object-type>
 
   <object-type name="QCoreApplication">
@@ -2532,7 +2480,7 @@
             <define-ownership class="java" owner="c++"/>
         </modify-argument>
     </modify-function>
-
+  
       <modify-function signature="QCoreApplication(int &amp;, char  **)">
           <inject-code class="shell">
               // qtjambi_register_variant_handler();
@@ -2579,7 +2527,7 @@
   <object-type name="QDataStream">
   <!-- qtd2 -->
   <modify-function signature="device() const" remove="all"/>
-
+  
     <modify-function signature="setDevice(QIODevice*)">
         <modify-argument index="1">
             <reference-count action="set" variable-name="__rcDevice"/>
@@ -2609,7 +2557,7 @@
     <modify-function signature="readBytes(char&amp;*,uint&amp;)"> <remove/> </modify-function>
     <modify-function signature="writeRawData(const char*,int)"> <remove/> </modify-function>
     <modify-function signature="writeBytes(const char*,uint)"> <remove/> </modify-function>
-
+  
       <template name="core.datastream_operator_shift_right">
           <insert-template name="core.stream_operator_shift_right">
               <replace from="%STREAM_TYPE" to="QDataStream"/>
@@ -2794,10 +2742,10 @@
   </object-type>
 
   <object-type name="QTextStream">
-
+  
       <modify-function signature="setCodec(QTextCodec *)" remove="all"/>
       <modify-function signature="codec() const" remove="all"/>
-
+  
     <modify-function signature="QTextStream(QByteArray *, QFlags&lt;QIODevice::OpenModeFlag&gt;)"> <remove/> </modify-function>
     <modify-function signature="QTextStream(QString*,QFlags&lt;QIODevice::OpenModeFlag&gt;)"> <remove/> </modify-function>
     <modify-function signature="operator&gt;&gt;(QChar&amp;)"> <remove/> </modify-function>
@@ -2884,7 +2832,7 @@
           <rename to="writeString"/>
           <modify-argument index="0" replace-value="this"/>
       </modify-function>
-
+      
       <modify-function signature="operator&gt;&gt;(char&amp;)">
           <access modifier="private"/>
           <modify-argument index="0" replace-value="this"/>
@@ -2959,7 +2907,7 @@
   <value-type name="QFuture" generate="no">
     <modify-function signature="operator T() const" remove="all"/>
     <modify-function signature="operator=(const QFuture &amp;)" remove="all"/>
-
+  
     <modify-function signature="operator==(const QFuture &amp;)const">
         <modify-argument index="1">
             <replace-type modified-type="qt.core.QFuture"/>
@@ -2972,7 +2920,7 @@
   <value-type name="QtJambiVoidFuture" java-name="QFutureVoid">
     <modify-function signature="resultCount()const" remove="all"/>
     <modify-function signature="isResultReadyAt(int)const" remove="all"/>
-
+  
     <modify-function signature="QFuture(const QFuture &amp;)">
         <modify-argument index="1">
             <replace-type modified-type="qt.core.QFutureVoid"/>
@@ -2996,7 +2944,7 @@
   <object-type name="QFutureWatcherBase">
     <modify-function signature="connectNotify(const char *)" remove="all"/>
     <modify-function signature="disconnectNotify(const char *)" remove="all"/>
-
+  
     <inject-code class="shell-declaration">
 
         // private, pure virtual and considered internal
@@ -3029,7 +2977,7 @@
 
   <object-type name="QFutureWatcher" generate="no">
     <modify-function signature="future()const" remove="all"/>
-
+  
     <modify-function signature="setFuture(const QFuture &amp;)">
         <modify-argument index="1">
             <replace-type modified-type="qt.core.QFuture&lt;T&gt;"/>
--- a/generator/typesystem_gui-java.java	Thu Aug 20 19:08:32 2009 +0000
+++ b/generator/typesystem_gui-java.java	Sat Aug 22 12:50:58 2009 +0000
@@ -170,20 +170,20 @@
 
     @QtBlockedSlot
     public final QPolygon add(int x, int y) {
-        add_private(__nativeId(), x, y);
+        add_private(nativeId(), x, y);
         return this;
     }
 
     @QtBlockedSlot
     public final QPolygon add(QPoint pt) {
-        add_private(__nativeId(), pt.x(), pt.y());
+        add_private(nativeId(), pt.x(), pt.y());
         return this;
     }
 
     @QtBlockedSlot
     public final QPolygon add(QPolygon p) {
         int size = p.size();
-        long nid = __nativeId();
+        long nid = nativeId();
         for (int i = 0; i < size; ++i) {
             QPoint pt = p.at(i);
             add_private(nid, pt.x(), pt.y());
@@ -199,20 +199,20 @@
 
     @QtBlockedSlot
     public final QPolygonF add(double x, double y) {
-        add_private(__nativeId(), x, y);
+        add_private(nativeId(), x, y);
         return this;
     }
 
     @QtBlockedSlot
     public final QPolygonF add(QPointF pt) {
-        add_private(__nativeId(), pt.x(), pt.y());
+        add_private(nativeId(), pt.x(), pt.y());
         return this;
     }
 
     @QtBlockedSlot
     public final QPolygonF add(QPolygonF p) {
         int size = p.size();
-        long nid = __nativeId();
+        long nid = nativeId();
         for (int i = 0; i < size; ++i) {
             QPointF pt = p.at(i);
             add_private(nid, pt.x(), pt.y());
@@ -859,14 +859,14 @@
     public static string getOpenFileName(QWidget _parent, string caption = null, string dir = null, string filter = null) {
         string res;
         string _selectedFilter = "";
-        qtd_QFileDialog_getOpenFileName_QWidget_string_string_string_nativepointerstring_Options(&res, _parent is null ? null : _parent.__nativeId, caption, dir, filter, _selectedFilter, 0);
+        qtd_QFileDialog_getOpenFileName_QWidget_string_string_string_nativepointerstring_Options(&res, _parent is null ? null : _parent.nativeId, caption, dir, filter, _selectedFilter, 0);
         return res;
     }
     
     public static string getSaveFileName(QWidget _parent, string caption = null, string dir = null, string filter = null) {
         string res;
         string _selectedFilter = "";
-        qtd_QFileDialog_getSaveFileName_QWidget_string_string_string_nativepointerstring_Options(&res, _parent is null ? null : _parent.__nativeId, caption, dir, filter, _selectedFilter, 0);
+        qtd_QFileDialog_getSaveFileName_QWidget_string_string_string_nativepointerstring_Options(&res, _parent is null ? null : _parent.nativeId, caption, dir, filter, _selectedFilter, 0);
         return res;
     }
     
@@ -1013,51 +1013,51 @@
     }
     
     public final void drawConvexPolygon(in QPoint[] points) {
-        qtd_QPainter_drawConvexPolygon_nativepointerQPoint_int(__nativeId, points.ptr, points.length);
+        qtd_QPainter_drawConvexPolygon_nativepointerQPoint_int(nativeId, points.ptr, points.length);
     }
     
     public final void drawConvexPolygon(in QPointF[] points) {
-        qtd_QPainter_drawConvexPolygon_nativepointerQPointF_int(__nativeId, points.ptr, points.length);
+        qtd_QPainter_drawConvexPolygon_nativepointerQPointF_int(nativeId, points.ptr, points.length);
     }
     
     public final void drawLines(in QLine[] lines) {
-        qtd_QPainter_drawLines_nativepointerQLine_int(__nativeId, lines.ptr, lines.length);
+        qtd_QPainter_drawLines_nativepointerQLine_int(nativeId, lines.ptr, lines.length);
     }
 
     public final void drawLines(in QLineF[] lines) {
-        qtd_QPainter_drawLines_nativepointerQLineF_int(__nativeId, lines.ptr, lines.length);
+        qtd_QPainter_drawLines_nativepointerQLineF_int(nativeId, lines.ptr, lines.length);
     }
     
     public final void drawPolygon(in QPoint[] points, Qt_FillRule fillRule = Qt_FillRule.OddEvenFill) {
-        qtd_QPainter_drawPolygon_nativepointerQPoint_int_FillRule(__nativeId, points.ptr, points.length, fillRule);
+        qtd_QPainter_drawPolygon_nativepointerQPoint_int_FillRule(nativeId, points.ptr, points.length, fillRule);
     }
 
     public final void drawPolygon(in QPointF[] points, Qt_FillRule fillRule = Qt_FillRule.OddEvenFill) {
-        qtd_QPainter_drawPolygon_nativepointerQPointF_int_FillRule(__nativeId, points.ptr, points.length, fillRule);
+        qtd_QPainter_drawPolygon_nativepointerQPointF_int_FillRule(nativeId, points.ptr, points.length, fillRule);
     }
 
     public final void drawPolyline(in QPoint[] points) {
-        qtd_QPainter_drawPolyline_nativepointerQPoint_int(__nativeId, points.ptr, points.length);
+        qtd_QPainter_drawPolyline_nativepointerQPoint_int(nativeId, points.ptr, points.length);
     }
 
     public final void drawPolyline(in QPointF[] points) {
-        qtd_QPainter_drawPolyline_nativepointerQPointF_int(__nativeId, points.ptr, points.length);
+        qtd_QPainter_drawPolyline_nativepointerQPointF_int(nativeId, points.ptr, points.length);
     }
     
     public final void drawPoints(in QPoint[] points) {
-        qtd_QPainter_drawPoints_nativepointerQPoint_int(__nativeId, points.ptr, points.length);
+        qtd_QPainter_drawPoints_nativepointerQPoint_int(nativeId, points.ptr, points.length);
     }
 
     public final void drawPoints(in QPointF[] points) {
-        qtd_QPainter_drawPoints_nativepointerQPointF_int(__nativeId, points.ptr, points.length);
+        qtd_QPainter_drawPoints_nativepointerQPointF_int(nativeId, points.ptr, points.length);
     }
     
     public final void drawRects(in QRect[] rects) {
-        qtd_QPainter_drawRects_nativepointerQRect_int(__nativeId, rects.ptr, rects.length);
+        qtd_QPainter_drawRects_nativepointerQRect_int(nativeId, rects.ptr, rects.length);
     }
 
     public final void drawRects(in QRectF[] rects) {
-        qtd_QPainter_drawRects_nativepointerQRectF_int(__nativeId, rects.ptr, rects.length);
+        qtd_QPainter_drawRects_nativepointerQRectF_int(nativeId, rects.ptr, rects.length);
     }
 /*
     public static QPaintDeviceInterface redirected(QPaintDeviceInterface device, qt.core.QPoint offset) {
@@ -1689,25 +1689,25 @@
 
 class QInputDialog___ extends QInputDialog {
     public static double getDouble(QWidget _parent, string title, string label, double value = 0, double minValue = -2147483647, double maxValue = 2147483647, int decimals = 1, ref bool ok = false, int flags = 0) {
-        return qtd_QInputDialog_getDouble_private_QWidget_string_string_double_double_double_int_nativepointerbool_WindowFlags(_parent is null ? null : _parent.__nativeId, title, label, value, minValue, maxValue, decimals, &ok, flags);
+        return qtd_QInputDialog_getDouble_private_QWidget_string_string_double_double_double_int_nativepointerbool_WindowFlags(_parent is null ? null : _parent.nativeId, title, label, value, minValue, maxValue, decimals, &ok, flags);
     }
     
     static if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0))
     {
 	public static int getInt(QWidget _parent, string title, string label, int value = 0, int minValue = -2147483647, int maxValue = 2147483647, int step = 1, ref bool ok = false, int flags = 0) {
-            return qtd_QInputDialog_getInt_private_QWidget_string_string_int_int_int_int_nativepointerbool_WindowFlags(_parent is null ? null : _parent.__nativeId, title, label, value, minValue, maxValue, step, &ok, flags);
+	    return qtd_QInputDialog_getInt_private_QWidget_string_string_int_int_int_int_nativepointerbool_WindowFlags(_parent is null ? null : _parent.nativeId, title, label, value, minValue, maxValue, step, &ok, flags);
 	}
     }
 
     public static string getItem(QWidget _parent, string title, string label, string[] items, int current = 0, bool editable = true, ref bool ok = false, int flags = 0) {
         string res;
-        qtd_QInputDialog_getItem_private_QWidget_string_string_List_int_bool_nativepointerbool_WindowFlags(&res, _parent is null ? null : _parent.__nativeId, title, label, items.ptr, items.length, current, editable, &ok, flags);
+        qtd_QInputDialog_getItem_private_QWidget_string_string_List_int_bool_nativepointerbool_WindowFlags(&res, _parent is null ? null : _parent.nativeId, title, label, items.ptr, items.length, current, editable, &ok, flags);
         return res;
     }
 
     public static string getText(QWidget _parent, string title, string label, QLineEdit_EchoMode echo = QLineEdit_EchoMode.Normal, string text = null, ref bool ok = false, int flags = 0) {
         string res;
-        qtd_QInputDialog_getText_private_QWidget_string_string_EchoMode_string_nativepointerbool_WindowFlags(&res, _parent is null ? null : _parent.__nativeId, title, label, echo, text, &ok, flags);
+        qtd_QInputDialog_getText_private_QWidget_string_string_EchoMode_string_nativepointerbool_WindowFlags(&res, _parent is null ? null : _parent.nativeId, title, label, echo, text, &ok, flags);
         return res;
     }
 }// class
@@ -1716,7 +1716,7 @@
     version(D_Version2) 
     {
 	void opAssign(in QFont arg__1)  {
-            this.__nativeId = qtd_QFont_QFont_QFont(arg__1 is null ? null : (cast(QFont)arg__1).__nativeId);
+	    this.nativeId = qtd_QFont_QFont_QFont(arg__1 is null ? null : (cast(QFont)arg__1).nativeId);
 	}
     }
 }// class"
--- a/generator/typesystem_gui-java.xml	Thu Aug 20 19:08:32 2009 +0000
+++ b/generator/typesystem_gui-java.xml	Sat Aug 22 12:50:58 2009 +0000
@@ -1,5 +1,5 @@
 <?xml version="1.0"?>
-<typesystem package="qt.gui" default-superclass="QtdObject">
+<typesystem package="qt.gui" default-superclass="QtDObject">
     <inject-code>
         qt.Utilities.loadQtLibrary("QtGui");
     </inject-code>
--- a/generator/typesystem_gui.xml	Thu Aug 20 19:08:32 2009 +0000
+++ b/generator/typesystem_gui.xml	Sat Aug 22 12:50:58 2009 +0000
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<typesystem package="qt.gui" default-superclass="QtdObject">
+<typesystem package="qt.gui" default-superclass="QtDObject">
 <depend package="qt.core" />
 <inject-code>
         qt.Utilities.loadQtLibrary("QtGui");
@@ -7,7 +7,7 @@
 
 <template name="gui.class_from_variant_java">
     public this(QVariant arg__1) {
-        void* __qt_return_value = qtd_%CLASS_NAME_%CLASS_NAME_QVariant(cast(void*) this, arg__1 is null ? null : arg__1.__nativeId);
+        void* __qt_return_value = qtd_%CLASS_NAME_%CLASS_NAME_QVariant(cast(void*) this, arg__1 is null ? null : arg__1.nativeId);
         super(__qt_return_value);
     }
 </template>
@@ -1138,11 +1138,11 @@
     
     <inject-code class="java">
     public final void insert(int i, QPoint t) {
-        qtd_QPolygon_insert_int_QPoint(__nativeId, i, t);
+        qtd_QPolygon_insert_int_QPoint(nativeId, i, t);
     }
     
     public final void insert(int i, int n, QPoint t) {
-        qtd_QPolygon_insert_int_int_QPoint(__nativeId, i, n, t);
+        qtd_QPolygon_insert_int_int_QPoint(nativeId, i, n, t);
     }
     </inject-code>
     <inject-code class="java-free">
@@ -1223,11 +1223,11 @@
 		-->
     <inject-code class="java">
     public final void insert(int i, QPointF t) {
-        qtd_QPolygonF_insert_int_QPointF(__nativeId, i, t);
+        qtd_QPolygonF_insert_int_QPointF(nativeId, i, t);
     }
 
     public final void insert(int i, int n, QPointF t) {
-        qtd_QPolygonF_insert_int_int_QPointF(__nativeId, i, n, t);
+        qtd_QPolygonF_insert_int_int_QPointF(nativeId, i, n, t);
     }
     </inject-code>
     <inject-code class="java-free">
@@ -5772,7 +5772,7 @@
                 qt.GeneratorUtilities.threadCheck(this);
                 if (nativeId() == 0)
                     throw new QNoNativeResourcesException("Function call on incomplete object of type: " +getClass().getName());
-                __qt_QMessageBox_setWindowModality(__nativeId(), %1.value());
+                __qt_QMessageBox_setWindowModality(nativeId(), %1.value());
                 return ;
             }
             </inject-code>
--- a/generator/typesystem_network-java.xml	Thu Aug 20 19:08:32 2009 +0000
+++ b/generator/typesystem_network-java.xml	Sat Aug 22 12:50:58 2009 +0000
@@ -1,5 +1,5 @@
 <?xml version="1.0"?>
-<typesystem package="qt.network" default-superclass="QtdObject">
+<typesystem package="qt.network" default-superclass="QtDObject">
     <inject-code>
         qt.Utilities.loadQtLibrary("QtNetwork");
     </inject-code>
--- a/generator/typesystem_network.xml	Thu Aug 20 19:08:32 2009 +0000
+++ b/generator/typesystem_network.xml	Sat Aug 22 12:50:58 2009 +0000
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<typesystem package="qt.network" default-superclass="QtdObject">
+<typesystem package="qt.network" default-superclass="QtDObject">
 <inject-code>
         qt.Utilities.loadQtLibrary("QtNetwork");
     </inject-code>
--- a/generator/typesystem_opengl-java.xml	Thu Aug 20 19:08:32 2009 +0000
+++ b/generator/typesystem_opengl-java.xml	Sat Aug 22 12:50:58 2009 +0000
@@ -1,5 +1,5 @@
 <?xml version="1.0"?>
-<typesystem package="qt.opengl" default-superclass="QtdObject">
+<typesystem package="qt.opengl" default-superclass="QtDObject">
   <inject-code>
     qt.Utilities.loadQtLibrary("QtGui");
     qt.Utilities.loadQtLibrary("QtOpenGL");
--- a/generator/typesystem_opengl.xml	Thu Aug 20 19:08:32 2009 +0000
+++ b/generator/typesystem_opengl.xml	Sat Aug 22 12:50:58 2009 +0000
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml-stylesheet type="text/xsl" href="merge.xsl"?>
 
-<typesystem package="qt.opengl" default-superclass="QtdObject">
+<typesystem package="qt.opengl" default-superclass="QtDObject">
 <depend package="qt.core" />
 <depend package="qt.gui" />
 <inject-code>
--- a/generator/typesystem_sql.xml	Thu Aug 20 19:08:32 2009 +0000
+++ b/generator/typesystem_sql.xml	Sat Aug 22 12:50:58 2009 +0000
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<typesystem package="qt.sql" default-superclass="qt.QtdObject">
+<typesystem package="qt.sql" default-superclass="qt.QtDObject">
 <inject-code>
         qt.Utilities.loadQtLibrary("QtSql");
     </inject-code>
--- a/generator/typesystem_svg-java.xml	Thu Aug 20 19:08:32 2009 +0000
+++ b/generator/typesystem_svg-java.xml	Sat Aug 22 12:50:58 2009 +0000
@@ -1,4 +1,4 @@
-<typesystem package="qt.svg" default-superclass="QtdObject">
+<typesystem package="qt.svg" default-superclass="QtDObject">
     <inject-code>
         qt.Utilities.loadQtLibrary("QtXml");
         qt.Utilities.loadQtLibrary("QtGui");
--- a/generator/typesystem_svg.xml	Thu Aug 20 19:08:32 2009 +0000
+++ b/generator/typesystem_svg.xml	Sat Aug 22 12:50:58 2009 +0000
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<typesystem package="qt.svg" default-superclass="QtdObject">
+<typesystem package="qt.svg" default-superclass="QtDObject">
 <inject-code>
         qt.Utilities.loadQtLibrary("QtXml");
         qt.Utilities.loadQtLibrary("QtGui");
--- a/generator/typesystem_webkit-java.xml	Thu Aug 20 19:08:32 2009 +0000
+++ b/generator/typesystem_webkit-java.xml	Sat Aug 22 12:50:58 2009 +0000
@@ -1,5 +1,5 @@
 <?xml version="1.0"?>
-<typesystem package="qt.webkit" default-superclass="QtdObject">
+<typesystem package="qt.webkit" default-superclass="QtDObject">
     <inject-code>
     qt.Utilities.loadQtLibrary("QtGui");
     qt.Utilities.loadQtLibrary("QtNetwork");
--- a/generator/typesystem_webkit.xml	Thu Aug 20 19:08:32 2009 +0000
+++ b/generator/typesystem_webkit.xml	Sat Aug 22 12:50:58 2009 +0000
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<typesystem package="qt.webkit" default-superclass="QtdObject">
+<typesystem package="qt.webkit" default-superclass="QtDObject">
 <inject-code>
     qt.Utilities.loadQtLibrary("QtGui");
     qt.Utilities.loadQtLibrary("QtNetwork");
--- a/generator/typesystem_xml.xml	Thu Aug 20 19:08:32 2009 +0000
+++ b/generator/typesystem_xml.xml	Sat Aug 22 12:50:58 2009 +0000
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml-stylesheet type="text/xsl" href="merge.xsl"?>
 
-<typesystem package="qt.xml" default-superclass="QtdObject">
+<typesystem package="qt.xml" default-superclass="QtDObject">
 <inject-code>
         com.trolltech.qt.Utilities.loadQtLibrary("QtXml");
     </inject-code>
--- a/include/QObjectEntity.h	Thu Aug 20 19:08:32 2009 +0000
+++ b/include/QObjectEntity.h	Sat Aug 22 12:50:58 2009 +0000
@@ -1,37 +1,16 @@
 #ifndef QQOBJECTENTITY_H
 #define QQOBJECTENTITY_H
 
-#include "qtd_core.h"
-#include <qobject.h>
-#include <iostream>
+#include <cstdlib>
 
-QTD_EXPORT(void, qtd_delete_d_qobject, (void* dPtr))
-
-#ifdef CPP_SHARED
-#define qtd_delete_d_qobject qtd_get_qtd_delete_d_qobject()
-#endif
-
-//TODO: user data ID must be registered with QObject::registerUserData;
-#define userDataId 0
-
-class QtD_QObjectEntity : public QtD_Entity, public QObjectUserData
+class Qtd_QObjectEntity
 {
 public:
+	Qtd_QObjectEntity(void *d_ptr) { _d_ptr = d_ptr; }
+	void *d_entity() const { return _d_ptr; }
 
-    QtD_QObjectEntity(QObject *qObject, void *dId) : QtD_Entity(dId)
-    {
-        qObject->setUserData(userDataId, this);
-    }
-
-    virtual ~QtD_QObjectEntity()
-    {
-        qtd_delete_d_qobject(dId);
-    }
-
-    inline static QtD_QObjectEntity* getQObjectEntity(const QObject *qObject)
-    {
-        return static_cast<QtD_QObjectEntity*>(qObject->userData(userDataId));
-    }
+private:
+	void *_d_ptr;
 };
 
 #endif // QQOBJECTENTITY_H
--- a/include/qtd_core.h	Thu Aug 20 19:08:32 2009 +0000
+++ b/include/qtd_core.h	Sat Aug 22 12:50:58 2009 +0000
@@ -21,16 +21,16 @@
 #endif
 
 #ifdef CPP_SHARED
-  #define QTD_EXPORT(TYPE, NAME, ARGS) \
+  #define QTD_EXPORT(TYPE, NAME, ARGS)      \
     extern "C" typedef TYPE (*pf_##NAME)ARGS; \
     extern "C" pf_##NAME qtd_get_##NAME();
   #define QTD_EXPORT_VAR(NAME) \
     pf_##NAME m_##NAME;        \
     extern "C" DLL_PUBLIC pf_##NAME qtd_get_##NAME() { return m_##NAME; }
-#define QTD_EXPORT_VAR_SET(NAME, VALUE) \
+  #define QTD_EXPORT_VAR_SET(NAME, VALUE) \
     m_##NAME = (pf_##NAME) VALUE
 #else
-  #define QTD_EXPORT(TYPE, NAME, ARGS) \
+  #define QTD_EXPORT(TYPE, NAME, ARGS)      \
     extern "C" TYPE NAME ARGS;
 #endif
 
@@ -46,23 +46,7 @@
     void* ptr;
 };
 
-enum QtdObjectFlags
-{
-    qNone,
-    qNativeOwnership            = 0x01,
-    qDOwnership                 = 0x02
-    //gcManaged                 = 0x04
-};
-
-class QtD_Entity
-{
-public:
-    void* dId;
-
-    QtD_Entity(void* id) : dId(id)
-    {
-    }
-};
+const uint USER_DATA_ID = 0;
 
 #define Array DArray
 
@@ -70,17 +54,15 @@
 typedef void (*pfunc_abstr)();
 #endif
 
-QTD_EXPORT(void, qtd_toUtf8, (const unsigned short* arr, uint size, void* str))
-QTD_EXPORT(void, qtd_dummy, ())
+QTD_EXPORT(void, _d_toUtf8, (const unsigned short* arr, uint size, void* str))
+QTD_EXPORT(void, __qtd_dummy, ())
 
 #ifdef CPP_SHARED
-#define qtd_toUtf8 qtd_get_qtd_toUtf8()
-#define qtd_dummy qtd_get_qtd_dummy()
+#define _d_toUtf8 qtd_get__d_toUtf8()
+#define __qtd_dummy qtd_get___qtd_dummy()
 #endif
 
 extern "C" QModelIndex qtd_to_QModelIndex(QModelIndexAccessor mia);
 extern "C" QModelIndexAccessor qtd_from_QModelIndex(const QModelIndex &index);
 
-
-
 #endif // QTD_CORE_H
--- a/qt/CMakeLists.txt	Thu Aug 20 19:08:32 2009 +0000
+++ b/qt/CMakeLists.txt	Sat Aug 22 12:50:58 2009 +0000
@@ -1,7 +1,7 @@
 project (qt_d D)
 
 set(QT_SRCS_D
-QtdObject.d
+QtDObject.d
 QGlobal.d
 
 core/QChildEvent.d
--- a/qt/QDefines.d	Thu Aug 20 19:08:32 2009 +0000
+++ b/qt/QDefines.d	Sat Aug 22 12:50:58 2009 +0000
@@ -1,4 +1,4 @@
-module qt.QDefines;
-
-const char[] QT_VERSION_STR = "4.5.1";
-const int QT_VERSION = 263425;
+module qt.QDefines;
+
+const char[] QT_VERSION_STR = "4.5.0";
+const int QT_VERSION = 0x040403;
\ No newline at end of file
--- a/qt/QGlobal.d	Thu Aug 20 19:08:32 2009 +0000
+++ b/qt/QGlobal.d	Sat Aug 22 12:50:58 2009 +0000
@@ -20,11 +20,6 @@
                    core.memory;
 }
 
-T static_cast(T, U)(U obj)
-{
-    return cast(T)cast(void*)obj;
-}
-
 template QT_BEGIN_NAMESPACE() {
 }
 
@@ -40,21 +35,13 @@
 mixin QT_BEGIN_HEADER;
 mixin QT_BEGIN_NAMESPACE;
 
-//TODO: this sucks
-extern(C) void qtd_dummy() {}
-// Defined in QObject.d
-extern(C) void qtd_delete_d_qobject(void* dPtr);
+extern(C) void __qtd_dummy() {}
 
 version(cpp_shared)
 {
-    extern (C) void qtd_core_initCallBacks(void* toUtf8, void* dummy);
+    extern (C) void __qtd_qtd_core_initCallBacks(void* toUtf8, void* dummy);
     static this() {
-        qtd_core_initCallBacks(&qtd_toUtf8, &qtd_dummy);
-    }
-
-    extern (C) void qtd_QObjectEntity_initCallBacks(void* del_d_obj);
-    static this() {
-        qtd_QObjectEntity_initCallBacks(&qtd_delete_d_qobject);
+        __qtd_qtd_core_initCallBacks(&_d_toUtf8, &__qtd_dummy);
     }
 }
 
@@ -707,7 +694,6 @@
     const InterfaceCountImpl = TInterfaces.length;
 }
 
-/+
 scope class StackObject(C)
 {
     byte[InstanceSize!(C)] data;
@@ -733,7 +719,6 @@
         }
     }
 }
-+/
 
 mixin QT_END_HEADER;
 
--- a/qt/core/QMetaObject.d	Thu Aug 20 19:08:32 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,136 +0,0 @@
-module qt.core.QMetaObject;
-
-import qt.QGlobal;
-import qt.core.QObject;
-import qt.QtdObject;
-
-final class QMetaObject
-{
-    private
-    {
-        void* _nativeId;
-        QMetaObject _base; // super class
-        QMetaObject _firstDerived; // head of the linked list of derived classes
-        QMetaObject _next; // next sibling on this derivation level
-        ClassInfo _classInfo;
-
-        QObject function(void* nativeId) _createWrapper;
-    }
-    
-    private void addDerived(QMetaObject mo)
-    {
-        mo._next = _firstDerived;
-        _firstDerived = mo;
-    }
-    
-    // NOTE: construction is split between this non-templated constructor and 'construct' function below.
-    this(void* nativeId, QMetaObject base)
-    {
-        _nativeId = nativeId;
-        if (base)
-        {
-            base.addDerived(this);
-            _base = base;
-        }
-    }
-    
-    // TODO: remove when D acquires templated constructors       
-    void construct(T : QObject, Concrete = T)()
-    {
-        _classInfo = T.classinfo;
-        
-        static QObject createWrapper(void* nativeId)
-        {
-            T obj = new Concrete(nativeId, QtdObjectFlags.nativeOwnership);
-            // TODO: this probably should be moved to QObject constructor
-            qtd_create_qobject_entity(nativeId, cast(void*)obj);
-            return obj;
-        }
-
-        _createWrapper = &createWrapper;        
-    }
-    
-    /++
-    +/
-    QMetaObject base()
-    {
-        return _base;
-    }
-    
-    /++
-    +/
-    void* nativeId()
-    {
-        return _nativeId;
-    }
-
-    /++
-    +/
-    ClassInfo classInfo()
-    {
-        return _classInfo;
-    }
-    
-    private QObject lookupDerived(void*[] moIds, void* nativeObjId)
-    {
-        assert (moIds.length >= 1);
-                
-        for (auto mo = _firstDerived; mo !is null; mo = mo._next)
-        {
-            if (mo._nativeId == moIds[0])
-            {
-                if (moIds.length == 1) // exact match found
-                    return mo._createWrapper(nativeObjId);
-                else // look deeper
-                    return mo.lookupDerived(moIds[1..$], nativeObjId);
-            }
-        }
-        
-        // no initialized wrapper that matches the native object.
-        // use the base class wrapper
-        return _createWrapper(nativeObjId);
-    }
-    
-    QObject getObject(void* nativeObjId)
-    {
-        QObject result;
-        
-        if (nativeObjId)
-        {
-            result = cast(QObject)qtd_get_d_qobject(nativeObjId);            
-            if (!result)
-            {
-                auto moId = qtd_QObject_metaObject(nativeObjId);
-                if (_nativeId == moId)
-                     result = _createWrapper(nativeObjId);
-                else
-                {
-                    // get native metaobjects for the entire derivation lattice
-                    // up to, but not including, the current metaobject.
-                    size_t moCount = 1;
-                    
-                    for (void* tmp = moId;;)
-                    {
-                        tmp = qtd_QMetaObject_superClass(tmp);                        
-                        assert(tmp);
-                        if (tmp == _nativeId)                        
-                            break;
-                        moCount++;
-                    }
-                   
-                    void*[] moIds = (cast(void**)alloca(moCount * (void*).sizeof))[0..moCount];
-
-                    moIds[--moCount] = moId;
-                    while (moCount > 0)
-                        moIds[--moCount] = moId = qtd_QMetaObject_superClass(moId);
-                                    
-                    result = lookupDerived(moIds, nativeObjId);                    
-                }
-            }
-        }
-
-        return result;
-    }
-}
-
-extern(C) void* qtd_QMetaObject_superClass(void* nativeId);
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/qt/d1/qt/QtDObject.d	Sat Aug 22 12:50:58 2009 +0000
@@ -0,0 +1,70 @@
+/**
+*
+*  Copyright: Copyright QtD Team, 2008-2009
+*  License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>
+*
+*  Copyright QtD Team, 2008-2009
+*  Distributed under the Boost Software License, Version 1.0.
+*  (See accompanying file boost-license-1.0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+*
+*/
+
+module qt.QtDObject;
+
+//import tango.util.container.HashMap;
+import qt.Signal;
+
+package class QtDObject
+{
+    public final void* nativeId() { return native__id; }
+
+	public final void nativeId(void *native_id) { native__id = native_id; }
+
+	private void* native__id = null;
+
+    mixin SignalHandlerOps;
+
+    public this()
+    {
+        /* intentionally empty */
+    }
+
+    package this(void* native_id, bool no_real_delete = false)
+    {
+        native__id = native_id;
+/*		auto qObj = cast(QObject) this;
+		if (qObj is null)
+		    register(native__id);*/
+        __no_real_delete = no_real_delete;
+    }
+/*
+	~this() {
+	    unregister(native__id);
+	}
+*/
+    // this flag controls if D object when destroying should or shouldn't delete real C++ object
+	public bool __no_real_delete = false;
+
+    package void __free_native_resources();
+
+
+	/*          hash table of Object instances            */
+/*    private static HashMap!(void*, Object) _map;
+
+	static this() {
+        _map = new HashMap!(void*, Object);
+	}
+
+	package static void register(void* qt_object, Object d_object) {
+	    _map.add(qt_object, d_object);
+	}
+
+	package static void unregister(void* qt_object) {
+	    _map.removeKey(qt_object);
+	}
+
+	package static Object lookup(void* qt_object) {
+	    return _map[qt_object];
+	}
+	*/
+}
\ No newline at end of file
--- a/qt/d1/qt/QtdObject.d	Thu Aug 20 19:08:32 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/**
-*
-*  Copyright: Copyright QtD Team, 2008-2009
-*  License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>
-*
-*  Copyright QtD Team, 2008-2009
-*  Distributed under the Boost Software License, Version 1.0.
-*  (See accompanying file boost-license-1.0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-*
-*/
-
-module qt.QtdObject;
-
-import qt.Signal;
-
-enum QtdObjectFlags : ubyte
-{
-    none,
-    nativeOwnership           = 0x1,
-    dOwnership                = 0x2,
-    //gcManaged               = 0x4
-}
-
-package abstract class QtdObject
-{
-private:
-    QtdObjectFlags __flags_;
-
-public:
-    void* __nativeId;
-    
-    mixin SignalHandlerOps;
-    
-    this(void* nativeId, QtdObjectFlags flags = QtdObjectFlags.none)
-    {
-        __nativeId = nativeId;
-        __flags_ = flags;
-    }
-
-    final QtdObjectFlags __flags()
-    {
-        return __flags_;
-    }
-
-    /+ final +/ void __setFlags(QtdObjectFlags flags, bool value)
-    {
-        if (value)
-            __flags_ |= flags;
-        else
-            __flags_ &= ~flags;
-    }
-
-    // COMPILER BUG: 3206
-    protected void __deleteNative()
-    {
-        assert(false);
-    }
-
-    ~this()
-    {
-        if (!(__flags_ & QtdObjectFlags.nativeOwnership))
-        {
-            // avoid deleting D object twice.
-            __flags_ |= QtdObjectFlags.dOwnership;
-            __deleteNative;
-        }
-    }
-}
\ No newline at end of file
--- a/qt/d1/qt/core/QLine.d	Thu Aug 20 19:08:32 2009 +0000
+++ b/qt/d1/qt/core/QLine.d	Sat Aug 22 12:50:58 2009 +0000
@@ -28,68 +28,68 @@
         ln.pt2 = QPoint(x2pos, y2pos);
         return ln;
     }
-
+    
     bool isNull() // const
     {
         return pt1 == pt2;
     }
-
+    
     int x1() // const
     {
         return pt1.x();
     }
-
+    
     int y1() // const
     {
         return pt1.y();
     }
-
+    
     int x2() // const
     {
         return pt2.x();
     }
-
+    
     int y2() // const
     {
         return pt2.y();
     }
-
+    
     QPoint p1() // const
     {
         return pt1;
     }
-
+    
     QPoint p2() // const
     {
         return pt2;
     }
-
+    
     int dx() // const
     {
         return pt2.x() - pt1.x();
     }
-
+    
     int dy() // const
     {
         return pt2.y() - pt1.y();
     }
-
+    
     void translate(in QPoint point)
     {
         pt1 += point;
         pt2 += point;
     }
-
+    
     void translate(int adx, int ady)
     {
         translate(QPoint(adx, ady));
     }
-
+    
     QLine translated(in QPoint p) // const
     {
         return QLine(pt1 + p, pt2 + p);
     }
-
+    
     QLine translated(int adx, int ady) // const
     {
         return translated(QPoint(adx, ady));
@@ -109,35 +109,35 @@
     {
         pt1 = aP1;
     }
-
+    
     void setP2(in QPoint aP2) // for convenience
     {
         pt2 = aP2;
     }
-
+    
     void setPoints(in QPoint aP1, in QPoint aP2)
     {
         pt1 = aP1;
         pt2 = aP2;
     }
-
+    
     void setLine(int aX1, int aY1, int aX2, int aY2)
     {
         pt1 = QPoint(aX1, aY1);
         pt2 = QPoint(aX2, aY2);
     }
-
+    
     bool opEquals(in QLine d) // const
     {
         return pt1 == d.pt1 && pt2 == d.pt2;
     }
 
     public final void writeTo(QDataStream arg__1) {
-        qtd_QLine_writeTo_QDataStream(this, arg__1 is null ? null : arg__1.__nativeId);
+        qtd_QLine_writeTo_QDataStream(this, arg__1 is null ? null : arg__1.nativeId);
     }
 
     public final void readFrom(QDataStream arg__1) {
-        qtd_QLine_readFrom_QDataStream(this, arg__1 is null ? null : arg__1.__nativeId);
+        qtd_QLine_readFrom_QDataStream(this, arg__1 is null ? null : arg__1.nativeId);
     }
 
 private:
@@ -153,112 +153,112 @@
 
 public struct QLineF
 {
-
+    
     alias QLineF_IntersectType IntersectType;
-
+    
     alias QLineF_IntersectType.NoIntersection NoIntersection;
     alias QLineF_IntersectType.BoundedIntersection BoundedIntersection;
     alias QLineF_IntersectType.UnboundedIntersection UnboundedIntersection;
-
+    
     public static QLineF opCall() {
         QLineF ln;
         ln.pt1 = QPointF();
         ln.pt2 = QPointF();
         return ln;
     }
-
+    
     public static QLineF opCall(in QPointF apt1, in QPointF apt2) {
         QLineF ln;
         ln.pt1 = apt1;
         ln.pt2 = apt2;
         return ln;
     }
-
+    
     public static QLineF opCall(qreal x1pos, qreal y1pos, qreal x2pos, qreal y2pos) {
         QLineF ln;
         ln.pt1 = QPointF(x1pos, y1pos);
         ln.pt2 = QPointF(x2pos, y2pos);
         return ln;
     }
-
-    public static QLineF opCall(in QLine line){
+    
+    public static QLineF opCall(in QLine line){ 
         QLineF ln;
         ln.pt1 = QPointF(line.p1());
         ln.pt2 = QPointF(line.p2());
         return ln;
     }
-
+    
     public final bool isNull() // const
     {
         return qtd_QLineF_isNull(this);
     }
-
+    
     qreal x1() // const
     {
         return pt1.x();
     }
-
+    
     qreal y1() // const
     {
         return pt1.y();
     }
-
+    
     qreal x2() // const
     {
         return pt2.x();
     }
-
+    
     qreal y2() // const
     {
         return pt2.y();
     }
-
+    
     QPointF p1() // const
     {
         return pt1;
     }
-
+    
     QPointF p2() // const
     {
         return pt2;
     }
-
+    
     qreal dx() // const
     {
         return pt2.x() - pt1.x();
     }
-
+    
     qreal dy() // const
     {
         return pt2.y() - pt1.y();
     }
-
+    
     QLineF normalVector() // const
     {
         return QLineF(p1(), p1() + QPointF(dy(), -dx()));
     }
-
+    
     void translate(in QPointF point)
     {
         pt1 += point;
         pt2 += point;
     }
-
+    
     void translate(qreal adx, qreal ady)
     {
         this.translate(QPointF(adx, ady));
     }
-
+    
     QLineF translated(in QPointF p) // const
     {
         return QLineF(pt1 + p, pt2 + p);
     }
-
+    
     QLineF translated(qreal adx, qreal ady) // const
     {
         return translated(QPointF(adx, ady));
     }
-
+    
     void setLength(qreal len)
     {
         if (isNull())
@@ -266,7 +266,7 @@
         QLineF v = unitVector();
         pt2 = QPointF(pt1.x() + v.dx() * len, pt1.y() + v.dy() * len);
     }
-
+    
     void length(qreal len)
     {
         if (isNull())
@@ -274,97 +274,97 @@
         QLineF v = unitVector();
         pt2 = QPointF(pt1.x() + v.dx() * len, pt1.y() + v.dy() * len);
     }
-
+    
     QPointF pointAt(qreal t) // const
     {
         qreal vx = pt2.x() - pt1.x();
         qreal vy = pt2.y() - pt1.y();
         return QPointF(pt1.x() + vx * t, pt1.y() + vy * t);
     }
-
+    
     QLine toLine() // const
     {
         return QLine(pt1.toPoint(), pt2.toPoint());
     }
-
+    
     void setP1(in QPointF aP1)
     {
         pt1 = aP1;
     }
-
+    
     void setP2(in QPointF aP2)
     {
         pt2 = aP2;
     }
-
+    
     void p1(in QPointF aP1)
     {
         pt1 = aP1;
     }
-
+    
     void p2(in QPointF aP2)
     {
         pt2 = aP2;
     }
-
+    
     void setPoints(in QPointF aP1, in QPointF aP2)
     {
         pt1 = aP1;
         pt2 = aP2;
     }
-
+    
     void setLine(qreal aX1, qreal aY1, qreal aX2, qreal aY2)
     {
         pt1 = QPointF(aX1, aY1);
         pt2 = QPointF(aX2, aY2);
     }
-
+    
     bool opEquals(in QLineF d) // const
     {
         return pt1 == d.pt1 && pt2 == d.pt2;
     }
-
+    
     public final double angle() {
         return qtd_QLineF_angle(this);
     }
-
+    
     public final double angle(in QLineF l) {
         return qtd_QLineF_angle_QLineF(this, &l);
     }
-
+    
     public final double angleTo(in QLineF l) {
         return qtd_QLineF_angleTo_QLineF(this, &l);
     }
-
+    
     // ### Qt 5: rename intersects() or intersection() and rename IntersectType IntersectionType
     private final QLineF_IntersectType intersect(in QLineF l, QPointF* intersectionPoint) {
         return cast(QLineF_IntersectType) qtd_QLineF_intersect_QLineF_nativepointerQPointF(this, &l, intersectionPoint);
     }
-
+    
     public final double length() {
         return qtd_QLineF_length(this);
     }
-
+    
     public final void writeTo(QDataStream arg__1) {
-        qtd_QLineF_writeTo_QDataStream(this, arg__1 is null ? null : arg__1.__nativeId);
+        qtd_QLineF_writeTo_QDataStream(this, arg__1 is null ? null : arg__1.nativeId);
     }
-
+    
     public final void readFrom(QDataStream arg__1) {
-        qtd_QLineF_readFrom_QDataStream(this, arg__1 is null ? null : arg__1.__nativeId);
+        qtd_QLineF_readFrom_QDataStream(this, arg__1 is null ? null : arg__1.nativeId);
     }
-
+    
     public final void setAngle(double angle) {
         qtd_QLineF_setAngle_double(this, angle);
     }
-
+    
     public final QLineF unitVector() {
         return qtd_QLineF_unitVector(this);
     }
-
+    
     public static QLineF fromPolar(double length, double angle) {
         return qtd_QLineF_fromPolar_double_double(length, angle);
     }
-
+    
     private:
         QPointF pt1, pt2;
 }
--- a/qt/d1/qt/core/QModelIndex.d	Thu Aug 20 19:08:32 2009 +0000
+++ b/qt/d1/qt/core/QModelIndex.d	Sat Aug 22 12:50:58 2009 +0000
@@ -1,7 +1,7 @@
 module qt.core.QModelIndex;
 
 public import qt.QGlobal;
-private import qt.QtdObject;
+private import qt.QtDObject;
 
 // automatic imports-------------
 private import qt.core.QVariant;
@@ -35,7 +35,7 @@
 
     public final QVariant data(int role = 0) {
         void* __qt_return_value = __qtd_QModelIndex_data_int(this, role);
-        return new QVariant(__qt_return_value);
+        return new QVariant(__qt_return_value, false);
     }
 
     public final int flags() {
@@ -64,7 +64,7 @@
         void* __qt_return_value = m;
         if (__qt_return_value is null)
             return null;
-        void* d_obj = qtd_get_d_qobject(__qt_return_value);
+        void* d_obj = __QObject_entity(__qt_return_value);
         return cast(QAbstractItemModel) d_obj;
     }
 
--- a/qt/d1/qt/core/QPoint.d	Thu Aug 20 19:08:32 2009 +0000
+++ b/qt/d1/qt/core/QPoint.d	Sat Aug 22 12:50:58 2009 +0000
@@ -61,7 +61,7 @@
 
     QPoint opMulAssign(qreal c)
     { xp = qRound(xp*c); yp = qRound(yp*c); return *this; }
-
+    
     bool opEquals(in QPoint p)
     { return xp == p.xp && yp == p.yp; }
 
@@ -70,7 +70,7 @@
 
     QPoint opSub(in QPoint p)
     { return QPoint(this.xp-p.xp, this.yp-p.yp); }
-
+    
     QPoint opMul(qreal c)
     { return QPoint(qRound(this.xp*c), qRound(this.yp*c)); }
 
@@ -87,11 +87,11 @@
     }
 
     public final void writeTo(QDataStream arg__1) {
-        qtd_QPoint_writeTo_QDataStream(this, arg__1 is null ? null : arg__1.__nativeId);
+        qtd_QPoint_writeTo_QDataStream(this, arg__1 is null ? null : arg__1.nativeId);
     }
 
     public final void readFrom(QDataStream arg__1) {
-        qtd_QPoint_readFrom_QDataStream(this, arg__1 is null ? null : arg__1.__nativeId);
+        qtd_QPoint_readFrom_QDataStream(this, arg__1 is null ? null : arg__1.nativeId);
     }
 
 private:
@@ -116,46 +116,46 @@
         pt.xp = pt.yp = 0;
         return pt;
     }
-
+    
     public static QPointF opCall(qreal xpos, qreal ypos) {
         QPointF pt;
         pt.xp = xpos;
         pt.yp = ypos;
         return pt;
     }
-
+    
     public static QPointF opCall(in QPoint p) {
         QPointF pt;
         pt.xp = p.x();
         pt.yp = p.y();
         return pt;
     }
-
+    
     bool isNull() //const
     {
         return qIsNull(xp) && qIsNull(yp);
     }
-
+    
     qreal x() //const
     {
         return xp;
     }
-
+    
     qreal y() //const
     {
         return yp;
     }
-
+    
     void x(qreal xpos)
     {
         xp = xpos;
     }
-
+    
     void y(qreal ypos)
     {
         yp = ypos;
     }
-/*
+/*    
 inline qreal &QPointF::rx()
 {
         return xp;
@@ -166,53 +166,53 @@
     return yp;
 }
 */
-
+    
     QPointF opAddAssign(in QPointF p)
     { xp+=p.xp; yp+=p.yp; return *this; }
-
+    
     QPointF opSubAssign(in QPointF p)
     { xp-=p.xp; yp-=p.yp; return *this; }
-
+    
     QPointF opMulAssign(qreal c)
     { xp*=c; yp*=c; return *this; }
-
+    
     bool opEquals(in QPointF p)
     { return qFuzzyCompare(xp, p.xp) && qFuzzyCompare(yp, p.yp); }
-
+    
     QPointF opAdd(in QPointF p)
     { return QPointF(this.xp+p.xp, this.yp+p.yp); }
-
+    
     QPointF opSub(in QPointF p)
     { return QPointF(this.xp-p.xp, this.yp-p.yp); }
-
+    
     QPointF opMul(qreal c)
     { return QPointF(this.xp*c, this.yp*c); }
-
+    
     QPointF opDivAssign(qreal c)
     {
         xp/=c;
         yp/=c;
         return *this;
     }
-
+    
     QPointF opDiv(qreal c)
     {
         return QPointF(xp/c, yp/c);
     }
-
+    
     QPoint toPoint() //const
     {
         return QPoint(qRound(xp), qRound(yp));
     }
-
+    
     public final void writeTo(QDataStream arg__1) {
-        qtd_QPointF_writeTo_QDataStream(this, arg__1 is null ? null : arg__1.__nativeId);
+        qtd_QPointF_writeTo_QDataStream(this, arg__1 is null ? null : arg__1.nativeId);
     }
-
+    
     public final void readFrom(QDataStream arg__1) {
-        qtd_QPointF_readFrom_QDataStream(this, arg__1 is null ? null : arg__1.__nativeId);
+        qtd_QPointF_readFrom_QDataStream(this, arg__1 is null ? null : arg__1.nativeId);
     }
-
+    
 private:
     qreal xp;
     qreal yp;
--- a/qt/d1/qt/core/QRect.d	Thu Aug 20 19:08:32 2009 +0000
+++ b/qt/d1/qt/core/QRect.d	Sat Aug 22 12:50:58 2009 +0000
@@ -313,11 +313,11 @@
     }
 
     public final void writeTo(QDataStream arg__1) {
-        qtd_QRect_writeTo_QDataStream(this, arg__1 is null ? null : arg__1.__nativeId);
+        qtd_QRect_writeTo_QDataStream(this, arg__1 is null ? null : arg__1.nativeId);
     }
 
     public final void readFrom(QDataStream arg__1) {
-        qtd_QRect_readFrom_QDataStream(this, arg__1 is null ? null : arg__1.__nativeId);
+        qtd_QRect_readFrom_QDataStream(this, arg__1 is null ? null : arg__1.nativeId);
     }
 
     public final QRect opAnd(in QRect r) {
@@ -335,7 +335,7 @@
     public final bool contains(QRect r, bool proper = false) {
         return qtd_QRect_contains_QRect_bool(this, &r, proper);
     }
-
+    
     public final bool intersects(QRect r) {
         return qtd_QRect_intersects_QRect(this, &r);
     }
@@ -343,7 +343,7 @@
     public final QRect normalized() {
         return qtd_QRect_normalized(this);
     }
-
+    
 private:
     version(OSX)
     {
--- a/qt/d1/qt/core/QRectF.d	Thu Aug 20 19:08:32 2009 +0000
+++ b/qt/d1/qt/core/QRectF.d	Sat Aug 22 12:50:58 2009 +0000
@@ -18,7 +18,7 @@
         rt.w = rt.h = 0.;
         return rt;
     }
-
+    
     public static QRectF opCall(qreal aleft, qreal atop, qreal awidth, qreal aheight)
     {
         QRectF rt;
@@ -76,28 +76,28 @@
 
     qreal left() // const
     { return xp; }
-
+    
     qreal top() // const
     { return yp; }
-
+    
     qreal right() // const
     { return xp + w; }
-
+    
     qreal bottom() // const
     { return yp + h; }
-
+    
     QPointF topLeft() // const
     { return QPointF(xp, yp); }
-
+    
     QPointF bottomRight() // const
     { return QPointF(xp+w, yp+h); }
-
+    
     QPointF topRight() // const
     { return QPointF(xp+w, yp); }
-
+    
     QPointF bottomLeft() // const
     { return QPointF(xp, yp+h); }
-
+    
     void setLeft(qreal pos) { qreal diff = pos - xp; xp += diff; w -= diff; }
 
     void setRight(qreal pos) { w = pos - xp; }
@@ -235,7 +235,7 @@
         w = s.width();
         h = s.height();
     }
-
+    
     bool contains(qreal ax, qreal ay) // conts
     {
         return contains(QPointF(ax, ay));
@@ -295,11 +295,11 @@
     }
 
     public final void writeTo(QDataStream arg__1) {
-        qtd_QRectF_writeTo_QDataStream(this, arg__1 is null ? null : arg__1.__nativeId);
+        qtd_QRectF_writeTo_QDataStream(this, arg__1 is null ? null : arg__1.nativeId);
     }
 
     public final void readFrom(QDataStream arg__1) {
-        qtd_QRectF_readFrom_QDataStream(this, arg__1 is null ? null : arg__1.__nativeId);
+        qtd_QRectF_readFrom_QDataStream(this, arg__1 is null ? null : arg__1.nativeId);
     }
 
     public final QRectF opOr(in QRectF r) {
--- a/qt/d1/qt/core/QVariant.d	Thu Aug 20 19:08:32 2009 +0000
+++ b/qt/d1/qt/core/QVariant.d	Sat Aug 22 12:50:58 2009 +0000
@@ -1,7 +1,7 @@
 module qt.core.QVariant;
 
 public import qt.QGlobal;
-private import qt.QtdObject;
+private import qt.QtDObject;
 private import qt.core.QMetaType;
 
 // automatic imports-------------
@@ -33,7 +33,7 @@
 }
 
 
-public class QVariant : QtdObject
+public class QVariant : QtDObject
 {
     enum Type {
         Invalid = 0,
@@ -93,7 +93,7 @@
 
         LastType = 0xffffffff // need this so that gcc >= 3.4 allocates 32 bits for Type
     }
-
+    
 // Functions
 
     private template getMetaId()
@@ -103,7 +103,7 @@
 	    if(i <= 0)
 		i = qRegisterMetaType!(T)(name);";
     }
-
+	
     static public QVariant fromValue(T)(T obj)
     {
 	QVariant var;
@@ -131,7 +131,7 @@
 	}
 	return var;
     }
-
+    
     static public QVariant opCall(T)(T obj)
     {
 	return fromValue(obj);
@@ -144,7 +144,7 @@
 
 
     public this(QDataStream s) {
-        void* __qt_return_value = qtd_QVariant_QVariant_QDataStream(s is null ? null : s.__nativeId);
+        void* __qt_return_value = qtd_QVariant_QVariant_QDataStream(s is null ? null : s.nativeId);
         super(__qt_return_value);
     }
 
@@ -162,25 +162,25 @@
 
 
     public this(QBitArray bitarray) {
-        void* __qt_return_value = qtd_QVariant_QVariant_QBitArray(bitarray is null ? null : bitarray.__nativeId);
+        void* __qt_return_value = qtd_QVariant_QVariant_QBitArray(bitarray is null ? null : bitarray.nativeId);
         super(__qt_return_value);
     }
 
 
     public this(QByteArray bytearray) {
-        void* __qt_return_value = qtd_QVariant_QVariant_QByteArray(bytearray is null ? null : bytearray.__nativeId);
+        void* __qt_return_value = qtd_QVariant_QVariant_QByteArray(bytearray is null ? null : bytearray.nativeId);
         super(__qt_return_value);
     }
 
 
     public this(QDate date) {
-        void* __qt_return_value = qtd_QVariant_QVariant_QDate(date is null ? null : date.__nativeId);
+        void* __qt_return_value = qtd_QVariant_QVariant_QDate(date is null ? null : date.nativeId);
         super(__qt_return_value);
     }
 
 
     public this(QDateTime datetime) {
-        void* __qt_return_value = qtd_QVariant_QVariant_QDateTime(datetime is null ? null : datetime.__nativeId);
+        void* __qt_return_value = qtd_QVariant_QVariant_QDateTime(datetime is null ? null : datetime.nativeId);
         super(__qt_return_value);
     }
 
@@ -204,7 +204,7 @@
 
 
     public this(QLocale locale) {
-        void* __qt_return_value = qtd_QVariant_QVariant_QLocale(locale is null ? null : locale.__nativeId);
+        void* __qt_return_value = qtd_QVariant_QVariant_QLocale(locale is null ? null : locale.nativeId);
         super(__qt_return_value);
     }
 
@@ -234,7 +234,7 @@
 
 
     public this(QRegExp regExp) {
-        void* __qt_return_value = qtd_QVariant_QVariant_QRegExp(regExp is null ? null : regExp.__nativeId);
+        void* __qt_return_value = qtd_QVariant_QVariant_QRegExp(regExp is null ? null : regExp.nativeId);
         super(__qt_return_value);
     }
 
@@ -252,19 +252,19 @@
 
 
     public this(QTime time) {
-        void* __qt_return_value = qtd_QVariant_QVariant_QTime(time is null ? null : time.__nativeId);
+        void* __qt_return_value = qtd_QVariant_QVariant_QTime(time is null ? null : time.nativeId);
         super(__qt_return_value);
     }
 
 
     public this(QUrl url) {
-        void* __qt_return_value = qtd_QVariant_QVariant_QUrl(url is null ? null : url.__nativeId);
+        void* __qt_return_value = qtd_QVariant_QVariant_QUrl(url is null ? null : url.nativeId);
         super(__qt_return_value);
     }
 
 
     public this(QVariant other) {
-        void* __qt_return_value = qtd_QVariant_QVariant_QVariant(other is null ? null : other.__nativeId);
+        void* __qt_return_value = qtd_QVariant_QVariant_QVariant(other is null ? null : other.nativeId);
         super(__qt_return_value);
     }
 
@@ -314,7 +314,7 @@
     {
 	int i = qtd_MetatypeId(toStringz(name));
 	assert(i > 0);
-	return qtd_QVariant_canConvert(__nativeId, i);
+	return qtd_QVariant_canConvert(nativeId, i);
     }
 
     public final bool canConvert(Type)() {
@@ -359,58 +359,58 @@
 	else  static if ( is(Type == QTime) )
 	    return canConvertImpl("QTime");
 	else static if ( is(Type == uint) )
-	    return canConvertImpl("unsigned int"); // TODO:
+	    return canConvertImpl("unsigned int"); // TODO: 
 	else static if ( is(Type == ulong) )
-	    return canConvertImpl("unsigned long long"); // TODO:
+	    return canConvertImpl("unsigned long long"); // TODO: 
 	else static if ( is(Type == QUrl) )
 	    return canConvertImpl("QUrl");
 	else
 	{
 	    static if( is( Type == class ) || is( Type == interface ) )
 	    {
-		Object object = cast(Object)qtd_QVariant_data(__nativeId);
+		Object object = cast(Object)qtd_QVariant_data(nativeId);
 		if(object)
 		    return cast(Type)(object) !is null;
 		return false;
 	    }
 	    else static if (isDynamicArrayType!(Type) || isStaticArrayType!(Type) )
 	    {
-		auto array = cast(DArrayToC*)qtd_QVariant_data(__nativeId);
+		auto array = cast(DArrayToC*)qtd_QVariant_data(nativeId);
 		return cast(Type)(array.array) !is null;
 	    }
 	    else
 	    {
 		int i = qtd_MetatypeId(toStringz(typeid(Type).toString));
-		return qtd_QVariant_canConvert(__nativeId, i);
+		return qtd_QVariant_canConvert(nativeId, i);
 	    }
 	}
     }
 
     public final Type value(Type)() {
 	static if ( is(Type == QBitArray) )
-	    return toBitArra;
+	    return toBitArra; 
 	else static if ( is(Type == bool) )
-	    return toBool;
+	    return toBool; 
 	else static if ( is(Type == QByteArray) )
-	    return toByteArray;
+	    return toByteArray; 
 	else static if ( is(Type == QDate) )
-	    return toDate;
+	    return toDate; 
 	else static if ( is(Type == QDateTime) )
-	    return toDateTime;
+	    return toDateTime; 
 	else static if ( is(Type == double) )
-	    return toDouble;
+	    return toDouble; 
 	else static if ( is(Type == int) )
-	    return toInt;
+	    return toInt; 
 	else static if ( is(Type == QLine) )
-	    return toLine;
+	    return toLine; 
 	else static if ( is(Type == QLineF) )
-	    return toLineF;
+	    return toLineF; 
 	else static if ( is(Type == QLocale) )
-	    return toLocale;
+	    return toLocale; 
 	else static if ( is(Type == long) )
-	    return toLongLong;
+	    return toLongLong; 
 	else static if ( is(Type == QPoint) )
-	    return toPoint;
+	    return toPoint; 
 	else static if ( is(Type == QPointF) )
 	    return toPointF;
 	else static if ( is(Type == QRect) )
@@ -435,188 +435,194 @@
 	    return toUrl;
 	else static if( is( Type == class ) || is( Type == interface ) )
 	{
-	    Object object = cast(Object)qtd_QVariant_data(__nativeId);
+	    Object object = cast(Object)qtd_QVariant_data(nativeId);
 	    if(object)
 		return cast(Type)(object);
 	    return null;
 	}
 	else static if (isDynamicArrayType!(Type) || isStaticArrayType!(Type) )
 	{
-	    auto array = cast(DArrayToC*)qtd_QVariant_data(__nativeId);
+	    auto array = cast(DArrayToC*)qtd_QVariant_data(nativeId);
 	    return cast(Type)(array.array);
 	}
 	else
 	{
-	    return *cast(Type*)qtd_QVariant_data(__nativeId);
+	    return *cast(Type*)qtd_QVariant_data(nativeId);
 	}
     }
 
     public final void clear() {
-        qtd_QVariant_clear(__nativeId);
+        qtd_QVariant_clear(nativeId);
     }
 
     protected final bool cmp(QVariant other) {
-        return qtd_QVariant_cmp_QVariant(__nativeId, other is null ? null : other.__nativeId);
+        return qtd_QVariant_cmp_QVariant(nativeId, other is null ? null : other.nativeId);
     }
 
     protected final void create(int type, void* copy) {
-        qtd_QVariant_create_int_nativepointervoid(__nativeId, type, copy);
+        qtd_QVariant_create_int_nativepointervoid(nativeId, type, copy);
     }
 
     public final bool isNull() {
-        return qtd_QVariant_isNull(__nativeId);
+        return qtd_QVariant_isNull(nativeId);
     }
 
     public final bool isValid() {
-        return qtd_QVariant_isValid(__nativeId);
+        return qtd_QVariant_isValid(nativeId);
     }
 
     public final void load(QDataStream ds) {
-        qtd_QVariant_load_QDataStream(__nativeId, ds is null ? null : ds.__nativeId);
+        qtd_QVariant_load_QDataStream(nativeId, ds is null ? null : ds.nativeId);
     }
 
     public final void writeTo(QDataStream s) {
-        qtd_QVariant_writeTo_QDataStream(__nativeId, s is null ? null : s.__nativeId);
+        qtd_QVariant_writeTo_QDataStream(nativeId, s is null ? null : s.nativeId);
     }
 
     public final QVariant operator_assign(QVariant other) {
-        void* __qt_return_value = qtd_QVariant_operator_assign_QVariant(__nativeId, other is null ? null : other.__nativeId);
-        return new QVariant(__qt_return_value, QtdObjectFlags.nativeOwnership);
+        void* __qt_return_value = qtd_QVariant_operator_assign_QVariant(nativeId, other is null ? null : other.nativeId);
+        return new QVariant(__qt_return_value, true);
     }
 
     private final bool operator_equal(QVariant v) {
-        return qtd_QVariant_operator_equal_QVariant(__nativeId, v is null ? null : v.__nativeId);
+        return qtd_QVariant_operator_equal_QVariant(nativeId, v is null ? null : v.nativeId);
     }
 
     public final void readFrom(QDataStream s) {
-        qtd_QVariant_readFrom_QDataStream(__nativeId, s is null ? null : s.__nativeId);
+        qtd_QVariant_readFrom_QDataStream(nativeId, s is null ? null : s.nativeId);
     }
 
     public final void save(QDataStream ds) {
-        qtd_QVariant_save_QDataStream(__nativeId, ds is null ? null : ds.__nativeId);
+        qtd_QVariant_save_QDataStream(nativeId, ds is null ? null : ds.nativeId);
     }
 
     public final QBitArray toBitArray() {
-        void* __qt_return_value = qtd_QVariant_toBitArray(__nativeId);
-        return new QBitArray(__qt_return_value);
+        void* __qt_return_value = qtd_QVariant_toBitArray(nativeId);
+        return new QBitArray(__qt_return_value, false);
     }
 
     public final bool toBool() {
-        return qtd_QVariant_toBool(__nativeId);
+        return qtd_QVariant_toBool(nativeId);
     }
 
     public final QByteArray toByteArray() {
-        void* __qt_return_value = qtd_QVariant_toByteArray(__nativeId);
-        return new QByteArray(__qt_return_value);
+        void* __qt_return_value = qtd_QVariant_toByteArray(nativeId);
+        return new QByteArray(__qt_return_value, false);
     }
 
     public final QDate toDate() {
-        void* __qt_return_value = qtd_QVariant_toDate(__nativeId);
-        return new QDate(__qt_return_value);
+        void* __qt_return_value = qtd_QVariant_toDate(nativeId);
+        return new QDate(__qt_return_value, false);
     }
 
     public final QDateTime toDateTime() {
-        void* __qt_return_value = qtd_QVariant_toDateTime(__nativeId);
-        return new QDateTime(__qt_return_value);
+        void* __qt_return_value = qtd_QVariant_toDateTime(nativeId);
+        return new QDateTime(__qt_return_value, false);
     }
 
     public final double toDouble(bool* ok = null) {
-        return qtd_QVariant_toDouble_nativepointerbool(__nativeId, ok);
+        return qtd_QVariant_toDouble_nativepointerbool(nativeId, ok);
     }
 
     public final int toInt(bool* ok = null) {
-        return qtd_QVariant_toInt_nativepointerbool(__nativeId, ok);
+        return qtd_QVariant_toInt_nativepointerbool(nativeId, ok);
     }
 
     public final QLine toLine() {
-        return qtd_QVariant_toLine(__nativeId);
+        return qtd_QVariant_toLine(nativeId);
     }
 
     public final QLineF toLineF() {
-        return qtd_QVariant_toLineF(__nativeId);
+        return qtd_QVariant_toLineF(nativeId);
     }
 
     public final QLocale toLocale() {
-        void* __qt_return_value = qtd_QVariant_toLocale(__nativeId);
-        return new QLocale(__qt_return_value);
+        void* __qt_return_value = qtd_QVariant_toLocale(nativeId);
+        return new QLocale(__qt_return_value, false);
     }
 
     public final long toLongLong(bool* ok = null) {
-        return qtd_QVariant_toLongLong_nativepointerbool(__nativeId, ok);
+        return qtd_QVariant_toLongLong_nativepointerbool(nativeId, ok);
     }
 
     public final QPoint toPoint() {
-        return qtd_QVariant_toPoint(__nativeId);
+        return qtd_QVariant_toPoint(nativeId);
     }
 
     public final QPointF toPointF() {
-        return qtd_QVariant_toPointF(__nativeId);
+        return qtd_QVariant_toPointF(nativeId);
     }
 
     public final QRect toRect() {
-        return qtd_QVariant_toRect(__nativeId);
+        return qtd_QVariant_toRect(nativeId);
     }
 
     public final QRectF toRectF() {
-        return qtd_QVariant_toRectF(__nativeId);
+        return qtd_QVariant_toRectF(nativeId);
     }
 
     public final QRegExp toRegExp() {
-        void* __qt_return_value = qtd_QVariant_toRegExp(__nativeId);
-        return new QRegExp(__qt_return_value);
+        void* __qt_return_value = qtd_QVariant_toRegExp(nativeId);
+        return new QRegExp(__qt_return_value, false);
     }
 
     public final QSize toSize() {
-        return qtd_QVariant_toSize(__nativeId);
+        return qtd_QVariant_toSize(nativeId);
     }
 
     public final QSizeF toSizeF() {
-        return qtd_QVariant_toSizeF(__nativeId);
+        return qtd_QVariant_toSizeF(nativeId);
     }
 
     public final string toString() {
         string res;
-        qtd_QVariant_toString(__nativeId, &res);
+        qtd_QVariant_toString(nativeId, &res);
         return res;
     }
 
     public final QTime toTime() {
-        void* __qt_return_value = qtd_QVariant_toTime(__nativeId);
-        return new QTime(__qt_return_value);
+        void* __qt_return_value = qtd_QVariant_toTime(nativeId);
+        return new QTime(__qt_return_value, false);
     }
 
     public final uint toUInt(bool* ok = null) {
-        return qtd_QVariant_toUInt_nativepointerbool(__nativeId, ok);
+        return qtd_QVariant_toUInt_nativepointerbool(nativeId, ok);
     }
 
     public final ulong toULongLong(bool* ok = null) {
-        return qtd_QVariant_toULongLong_nativepointerbool(__nativeId, ok);
+        return qtd_QVariant_toULongLong_nativepointerbool(nativeId, ok);
     }
 
     public final QUrl toUrl() {
-        void* __qt_return_value = qtd_QVariant_toUrl(__nativeId);
-        return new QUrl(__qt_return_value);
+        void* __qt_return_value = qtd_QVariant_toUrl(nativeId);
+        return new QUrl(__qt_return_value, false);
     }
 
     public final char* typeName() {
-        return qtd_QVariant_typeName(__nativeId);
+        return qtd_QVariant_typeName(nativeId);
     }
-
+    
     public final Type type() {
-        return cast(Type)qtd_QVariant_type(__nativeId);
+        return cast(Type)qtd_QVariant_type(nativeId);
     }
 
     public final int userType() {
-        return qtd_QVariant_userType(__nativeId);
+        return qtd_QVariant_userType(nativeId);
     }
 // Field accessors
 
-    public this(void* native_id, QtdObjectFlags flags = QtdObjectFlags.none) {
-        super(native_id, flags);
+    public this(void* native_id, bool no_real_delete = false) {
+        super(native_id, no_real_delete);
     }
 
-    protected override void __deleteNative() {
-        qtd_QVariant_destructor(__nativeId);
+
+    ~this() {
+        if(!__no_real_delete)
+            __free_native_resources();
+    }
+
+    protected void __free_native_resources() {
+        qtd_QVariant_destructor(nativeId());
     }
 
 // Injected code in class
--- a/qt/d1/qt/qtd/Str.d	Thu Aug 20 19:08:32 2009 +0000
+++ b/qt/d1/qt/qtd/Str.d	Sat Aug 22 12:50:58 2009 +0000
@@ -11,11 +11,11 @@
 
 module qt.qtd.Str;
 
-    import tango.text.convert.Utf : toString;
+import tango.text.convert.Utf : toString;
 public import tango.stdc.stringz : fromStringz;
 
-    alias char[] string;
-    alias wchar[] wstring;
+alias char[] string;
+alias wchar[] wstring;
 
 alias char* stringz;
 alias char* cstringz;
@@ -36,8 +36,20 @@
 
 	return argv;
 }
-extern(C) void qtd_toUtf8(wchar* arr, uint size, string* str){
-    *str = toString(arr[0..size]);
+
+version(Windows)
+{
+    export extern(C) void _d_toUtf8(wchar* arr, uint size, string* str)
+    {
+        *str = toString(arr[0..size]);
+    }
+}
+else
+{
+    extern(C) void _d_toUtf8(wchar* arr, uint size, string* str)
+    {
+        *str = toString(arr[0..size]);
+    }
 }
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/qt/d2/qt/QtDObject.d	Sat Aug 22 12:50:58 2009 +0000
@@ -0,0 +1,71 @@
+/**
+*
+*  Copyright: Copyright QtD Team, 2008-2009
+*  License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>
+*
+*  Copyright QtD Team, 2008-2009
+*  Distributed under the Boost Software License, Version 1.0.
+*  (See accompanying file boost-license-1.0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+*
+*/
+
+module qt.QtDObject;
+
+//import tango.util.container.HashMap;
+import qt.Signal;
+
+package class QtDObject
+{
+//    public final const(void*) nativeId() const { return native__id; }
+    public final void* nativeId() { return native__id; }
+
+    public final void nativeId(void *native_id) { native__id = native_id; }
+
+    private void* native__id = null;
+
+    mixin SignalHandlerOps;
+
+    public this()
+    {
+        /* intentionally empty */
+    }
+
+    package this(void* native_id, bool no_real_delete = false)
+    {
+        native__id = native_id;
+/*		auto qObj = cast(QObject) this;
+		if (qObj is null)
+		    register(native__id);*/
+        __no_real_delete = no_real_delete;
+    }
+/*
+	~this() {
+	    unregister(native__id);
+	}
+*/
+    // this flag controls if D object when destroying should or shouldn't delete real C++ object
+	public bool __no_real_delete = false;
+
+    package void __free_native_resources();
+
+
+	/*          hash table of Object instances            */
+/*    private static HashMap!(void*, Object) _map;
+
+	static this() {
+        _map = new HashMap!(void*, Object);
+	}
+
+	package static void register(void* qt_object, Object d_object) {
+	    _map.add(qt_object, d_object);
+	}
+
+	package static void unregister(void* qt_object) {
+	    _map.removeKey(qt_object);
+	}
+
+	package static Object lookup(void* qt_object) {
+	    return _map[qt_object];
+	}
+	*/
+}
\ No newline at end of file
--- a/qt/d2/qt/QtdObject.d	Thu Aug 20 19:08:32 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/**
-*
-*  Copyright: Copyright QtD Team, 2008-2009
-*  License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>
-*
-*  Copyright QtD Team, 2008-2009
-*  Distributed under the Boost Software License, Version 1.0.
-*  (See accompanying file boost-license-1.0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-*
-*/
-
-module qt.QtdObject;
-
-import qt.Signal;
-
-enum QtdObjectFlags : ubyte
-{
-    none,
-    nativeOwnership           = 0x1,
-    dOwnership                = 0x2,
-    //gcManaged               = 0x4
-}
-
-package abstract class QtdObject
-{
-private:
-    QtdObjectFlags __flags_;
-
-public:
-    void* __nativeId;
-
-    mixin SignalHandlerOps;
-        
-    this(void* nativeId, QtdObjectFlags flags = QtdObjectFlags.none)
-    {
-        __nativeId = nativeId;
-        __flags_ = flags;
-    }
-
-    final QtdObjectFlags __flags()
-    {
-        return __flags_;
-    }
-
-    /+ final +/ void __setFlags(QtdObjectFlags flags, bool value)
-    {
-        if (value)
-            __flags_ |= flags;
-        else
-            __flags_ &= ~flags;
-    }
-
-    // COMPILER BUG: 3206
-    protected void __deleteNative()
-    {
-        assert(false);
-    }
-
-    ~this()
-    {
-        if (!(__flags_ & QtdObjectFlags.nativeOwnership))
-        {
-            // avoid deleting D object twice.
-            __flags_ |= QtdObjectFlags.dOwnership;
-            __deleteNative;
-        }
-    }
-}
--- a/qt/d2/qt/core/QLine.d	Thu Aug 20 19:08:32 2009 +0000
+++ b/qt/d2/qt/core/QLine.d	Sat Aug 22 12:50:58 2009 +0000
@@ -24,68 +24,68 @@
         pt1 = QPoint(x1pos, y1pos);
         pt2 = QPoint(x2pos, y2pos);
     }
-
+    
     bool isNull() // const
     {
         return pt1 == pt2;
     }
-
+    
     int x1() // const
     {
         return pt1.x();
     }
-
+    
     int y1() // const
     {
         return pt1.y();
     }
-
+    
     int x2() // const
     {
         return pt2.x();
     }
-
+    
     int y2() // const
     {
         return pt2.y();
     }
-
+    
     QPoint p1() // const
     {
         return pt1;
     }
-
+    
     QPoint p2() // const
     {
         return pt2;
     }
-
+    
     int dx() // const
     {
         return pt2.x() - pt1.x();
     }
-
+    
     int dy() // const
     {
         return pt2.y() - pt1.y();
     }
-
+    
     void translate(ref QPoint point)
     {
         pt1 += point;
         pt2 += point;
     }
-
+    
     void translate(int adx, int ady)
     {
         translate(QPoint(adx, ady));
     }
-
+    
     QLine translated(ref QPoint p) // const
     {
         return QLine(pt1 + p, pt2 + p);
     }
-
+    
     QLine translated(int adx, int ady) // const
     {
         return translated(QPoint(adx, ady));
@@ -105,35 +105,35 @@
     {
         pt1 = aP1;
     }
-
+    
     void setP2(ref QPoint aP2) // for convenience
     {
         pt2 = aP2;
     }
-
+    
     void setPoints(ref QPoint aP1, ref QPoint aP2)
     {
         pt1 = aP1;
         pt2 = aP2;
     }
-
+    
     void setLine(int aX1, int aY1, int aX2, int aY2)
     {
         pt1 = QPoint(aX1, aY1);
         pt2 = QPoint(aX2, aY2);
     }
-
+    
     bool opEquals(ref QLine d) // const
     {
         return pt1 == d.pt1 && pt2 == d.pt2;
     }
 
     public final void writeTo(QDataStream arg__1) {
-        qtd_QLine_writeTo_QDataStream(&this, arg__1 is null ? null : arg__1.__nativeId);
+        qtd_QLine_writeTo_QDataStream(&this, arg__1 is null ? null : arg__1.nativeId);
     }
 
     public final void readFrom(QDataStream arg__1) {
-        qtd_QLine_readFrom_QDataStream(&this, arg__1 is null ? null : arg__1.__nativeId);
+        qtd_QLine_readFrom_QDataStream(&this, arg__1 is null ? null : arg__1.nativeId);
     }
 
 private:
@@ -149,106 +149,106 @@
 
 public struct QLineF
 {
-
+    
     alias QLineF_IntersectType IntersectType;
-
+    
     alias QLineF_IntersectType.NoIntersection NoIntersection;
     alias QLineF_IntersectType.BoundedIntersection BoundedIntersection;
     alias QLineF_IntersectType.UnboundedIntersection UnboundedIntersection;
-
+    
     public static QLineF opCall() {
         QLineF ln;
         ln.pt1 = QPointF();
         ln.pt2 = QPointF();
         return ln;
     }
-
+    
     public this(QPointF apt1, QPointF apt2) {
         pt1 = apt1;
         pt2 = apt2;
     }
-
+    
     public this(qreal x1pos, qreal y1pos, qreal x2pos, qreal y2pos) {
         pt1 = QPointF(x1pos, y1pos);
         pt2 = QPointF(x2pos, y2pos);
     }
-
-    public this(QLine line){
+    
+    public this(QLine line){ 
         pt1 = QPointF(line.p1());
         pt2 = QPointF(line.p2());
     }
-
+    
     public final bool isNull() // const
     {
         return qtd_QLineF_isNull(&this);
     }
-
+    
     qreal x1() // const
     {
         return pt1.x();
     }
-
+    
     qreal y1() // const
     {
         return pt1.y();
     }
-
+    
     qreal x2() // const
     {
         return pt2.x();
     }
-
+    
     qreal y2() // const
     {
         return pt2.y();
     }
-
+    
     QPointF p1() // const
     {
         return pt1;
     }
-
+    
     QPointF p2() // const
     {
         return pt2;
     }
-
+    
     qreal dx() // const
     {
         return pt2.x() - pt1.x();
     }
-
+    
     qreal dy() // const
     {
         return pt2.y() - pt1.y();
     }
-
+    
     QLineF normalVector() // const
     {
         return QLineF(p1(), p1() + QPointF(dy(), -dx()));
     }
-
+    
     void translate(ref QPointF point)
     {
         pt1 += point;
         pt2 += point;
     }
-
+    
     void translate(qreal adx, qreal ady)
     {
         this.translate(QPointF(adx, ady));
     }
-
+    
     QLineF translated(ref QPointF p) // const
     {
         return QLineF(pt1 + p, pt2 + p);
     }
-
+    
     QLineF translated(qreal adx, qreal ady) // const
     {
         return translated(QPointF(adx, ady));
     }
-
+    
     void setLength(qreal len)
     {
         if (isNull())
@@ -256,7 +256,7 @@
         QLineF v = unitVector();
         pt2 = QPointF(pt1.x() + v.dx() * len, pt1.y() + v.dy() * len);
     }
-
+    
     void length(qreal len)
     {
         if (isNull())
@@ -264,97 +264,97 @@
         QLineF v = unitVector();
         pt2 = QPointF(pt1.x() + v.dx() * len, pt1.y() + v.dy() * len);
     }
-
+    
     QPointF pointAt(qreal t) // const
     {
         qreal vx = pt2.x() - pt1.x();
         qreal vy = pt2.y() - pt1.y();
         return QPointF(pt1.x() + vx * t, pt1.y() + vy * t);
     }
-
+    
     QLine toLine() // const
     {
         return QLine(pt1.toPoint(), pt2.toPoint());
     }
-
+    
     void setP1(ref QPointF aP1)
     {
         pt1 = aP1;
     }
-
+    
     void setP2(ref QPointF aP2)
     {
         pt2 = aP2;
     }
-
+    
     void p1(ref QPointF aP1)
     {
         pt1 = aP1;
     }
-
+    
     void p2(ref QPointF aP2)
     {
         pt2 = aP2;
     }
-
+    
     void setPoints(ref QPointF aP1, ref QPointF aP2)
     {
         pt1 = aP1;
         pt2 = aP2;
     }
-
+    
     void setLine(qreal aX1, qreal aY1, qreal aX2, qreal aY2)
     {
         pt1 = QPointF(aX1, aY1);
         pt2 = QPointF(aX2, aY2);
     }
-
+    
     bool opEquals(ref QLineF d) // const
     {
         return pt1 == d.pt1 && pt2 == d.pt2;
     }
-
+    
     public final double angle() {
         return qtd_QLineF_angle(&this);
     }
-
+    
     public final double angle(ref QLineF l) {
         return qtd_QLineF_angle_QLineF(&this, &l);
     }
-
+    
     public final double angleTo(ref QLineF l) {
         return qtd_QLineF_angleTo_QLineF(&this, &l);
     }
-
+    
     // ### Qt 5: rename intersects() or intersection() and rename IntersectType IntersectionType
     private final QLineF_IntersectType intersect(ref QLineF l, QPointF* intersectionPoint) {
         return cast(QLineF_IntersectType) qtd_QLineF_intersect_QLineF_nativepointerQPointF(&this, &l, intersectionPoint);
     }
-
+    
     public final double length() {
         return qtd_QLineF_length(&this);
     }
-
+    
     public final void writeTo(QDataStream arg__1) {
-        qtd_QLineF_writeTo_QDataStream(&this, arg__1 is null ? null : arg__1.__nativeId);
+        qtd_QLineF_writeTo_QDataStream(&this, arg__1 is null ? null : arg__1.nativeId);
     }
-
+    
     public final void readFrom(QDataStream arg__1) {
-        qtd_QLineF_readFrom_QDataStream(&this, arg__1 is null ? null : arg__1.__nativeId);
+        qtd_QLineF_readFrom_QDataStream(&this, arg__1 is null ? null : arg__1.nativeId);
     }
-
+    
     public final void setAngle(double angle) {
         qtd_QLineF_setAngle_double(&this, angle);
     }
-
+    
     public final QLineF unitVector() {
         return qtd_QLineF_unitVector(&this);
     }
-
+    
     public static QLineF fromPolar(double length, double angle) {
         return qtd_QLineF_fromPolar_double_double(length, angle);
     }
-
+    
     private:
         QPointF pt1, pt2;
 }
--- a/qt/d2/qt/core/QModelIndex.d	Thu Aug 20 19:08:32 2009 +0000
+++ b/qt/d2/qt/core/QModelIndex.d	Sat Aug 22 12:50:58 2009 +0000
@@ -1,7 +1,7 @@
 module qt.core.QModelIndex;
 
 public import qt.QGlobal;
-private import qt.core.QObject;
+private import qt.QtDObject;
 
 // automatic imports-------------
 private import qt.core.QVariant;
@@ -17,7 +17,7 @@
          mi.p = mi.m = null;
          return mi;
     }
-
+    
     public final QModelIndex child(int row, int column) {
         return __qtd_QModelIndex_child_int_int(&this, row, column);
     }
@@ -28,7 +28,7 @@
 
     public final QVariant data(int role = 0) {
         void* __qt_return_value = __qtd_QModelIndex_data_int(&this, role);
-        return new QVariant(__qt_return_value);
+        return new QVariant(__qt_return_value, false);
     }
 
     public final int flags() {
@@ -57,7 +57,7 @@
         void* __qt_return_value = m;
         if (__qt_return_value is null)
             return null;
-        void* d_obj = qtd_get_d_qobject(__qt_return_value);
+        void* d_obj = __QObject_entity(__qt_return_value);
         return cast(QAbstractItemModel) d_obj;
     }
 
--- a/qt/d2/qt/core/QPoint.d	Thu Aug 20 19:08:32 2009 +0000
+++ b/qt/d2/qt/core/QPoint.d	Sat Aug 22 12:50:58 2009 +0000
@@ -60,7 +60,7 @@
 
     QPoint opMulAssign(qreal c)
     { xp = qRound(xp*c); yp = qRound(yp*c); return this; }
-
+    
     bool opEquals(ref QPoint p)
     { return xp == p.xp && yp == p.yp; }
 
@@ -69,7 +69,7 @@
 
     QPoint opSub(ref QPoint p)
     { return QPoint(this.xp-p.xp, this.yp-p.yp); }
-
+    
     QPoint opMul(qreal c)
     { return QPoint(qRound(this.xp*c), qRound(this.yp*c)); }
 
@@ -86,11 +86,11 @@
     }
 
     public final void writeTo(QDataStream arg__1) {
-        qtd_QPoint_writeTo_QDataStream(&this, arg__1 is null ? null : arg__1.__nativeId);
+        qtd_QPoint_writeTo_QDataStream(&this, arg__1 is null ? null : arg__1.nativeId);
     }
 
     public final void readFrom(QDataStream arg__1) {
-        qtd_QPoint_readFrom_QDataStream(&this, arg__1 is null ? null : arg__1.__nativeId);
+        qtd_QPoint_readFrom_QDataStream(&this, arg__1 is null ? null : arg__1.nativeId);
     }
 
 private:
@@ -115,42 +115,42 @@
         pt.xp = pt.yp = 0;
         return pt;
     }
-
+    
     public this(qreal xpos, qreal ypos) {
         xp = xpos;
         yp = ypos;
     }
-
+    
     public this(QPoint p) {
         xp = p.x();
         yp = p.y();
     }
-
+    
     bool isNull() //const
     {
         return qIsNull(xp) && qIsNull(yp);
     }
-
+    
     qreal x() //const
     {
         return xp;
     }
-
+    
     qreal y() //const
     {
         return yp;
     }
-
+    
     void x(qreal xpos)
     {
         xp = xpos;
     }
-
+    
     void y(qreal ypos)
     {
         yp = ypos;
     }
-/*
+/*    
 inline qreal &QPointF::rx()
 {
         return xp;
@@ -161,53 +161,53 @@
     return yp;
 }
 */
-
+    
     QPointF opAddAssign(ref QPointF p)
     { xp+=p.xp; yp+=p.yp; return this; }
-
+    
     QPointF opSubAssign(ref QPointF p)
     { xp-=p.xp; yp-=p.yp; return this; }
-
+    
     QPointF opMulAssign(qreal c)
     { xp*=c; yp*=c; return this; }
-
+    
     bool opEquals(ref QPointF p)
     { return qFuzzyCompare(xp, p.xp) && qFuzzyCompare(yp, p.yp); }
-
+    
     QPointF opAdd(ref QPointF p)
     { return QPointF(this.xp+p.xp, this.yp+p.yp); }
-
+    
     QPointF opSub(ref QPointF p)
     { return QPointF(this.xp-p.xp, this.yp-p.yp); }
-
+    
     QPointF opMul(qreal c)
     { return QPointF(this.xp*c, this.yp*c); }
-
+    
     QPointF opDivAssign(qreal c)
     {
         xp/=c;
         yp/=c;
         return this;
     }
-
+    
     QPointF opDiv(qreal c)
     {
         return QPointF(xp/c, yp/c);
     }
-
+    
     QPoint toPoint() //const
     {
         return QPoint(qRound(xp), qRound(yp));
     }
-
+    
     public final void writeTo(QDataStream arg__1) {
-        qtd_QPointF_writeTo_QDataStream(&this, arg__1 is null ? null : arg__1.__nativeId);
+        qtd_QPointF_writeTo_QDataStream(&this, arg__1 is null ? null : arg__1.nativeId);
     }
-
+    
     public final void readFrom(QDataStream arg__1) {
-        qtd_QPointF_readFrom_QDataStream(&this, arg__1 is null ? null : arg__1.__nativeId);
+        qtd_QPointF_readFrom_QDataStream(&this, arg__1 is null ? null : arg__1.nativeId);
     }
-
+    
 private:
     qreal xp;
     qreal yp;
--- a/qt/d2/qt/core/QRect.d	Thu Aug 20 19:08:32 2009 +0000
+++ b/qt/d2/qt/core/QRect.d	Sat Aug 22 12:50:58 2009 +0000
@@ -306,11 +306,11 @@
     }
 
     public final void writeTo(QDataStream arg__1) {
-        qtd_QRect_writeTo_QDataStream(&this, arg__1 is null ? null : arg__1.__nativeId);
+        qtd_QRect_writeTo_QDataStream(&this, arg__1 is null ? null : arg__1.nativeId);
     }
 
     public final void readFrom(QDataStream arg__1) {
-        qtd_QRect_readFrom_QDataStream(&this, arg__1 is null ? null : arg__1.__nativeId);
+        qtd_QRect_readFrom_QDataStream(&this, arg__1 is null ? null : arg__1.nativeId);
     }
 
     public final QRect opAnd(const QRect r) const {
@@ -328,7 +328,7 @@
     public final bool contains(const QRect r, bool proper = false) const {
         return qtd_QRect_contains_QRect_bool(&this, &r, proper);
     }
-
+    
     public final bool intersects(const QRect r) const {
         return qtd_QRect_intersects_QRect(&this, &r);
     }
@@ -336,7 +336,7 @@
     public final QRect normalized() const {
         return qtd_QRect_normalized(&this);
     }
-
+    
 private:
     version(OSX)
     {
--- a/qt/d2/qt/core/QRectF.d	Thu Aug 20 19:08:32 2009 +0000
+++ b/qt/d2/qt/core/QRectF.d	Sat Aug 22 12:50:58 2009 +0000
@@ -17,7 +17,7 @@
         rt.w = rt.h = 0.;
         return rt;
     }
-
+    
     public this(qreal aleft, qreal atop, qreal awidth, qreal aheight)
     {
         xp = aleft;
@@ -67,28 +67,28 @@
 
     qreal left() const
     { return xp; }
-
+    
     qreal top() const
     { return yp; }
-
+    
     qreal right() const
     { return xp + w; }
-
+    
     qreal bottom() const
     { return yp + h; }
-
+    
     QPointF topLeft() const
     { return QPointF(xp, yp); }
-
+    
     QPointF bottomRight() const
     { return QPointF(xp+w, yp+h); }
-
+    
     QPointF topRight() const
     { return QPointF(xp+w, yp); }
-
+    
     QPointF bottomLeft() const
     { return QPointF(xp, yp+h); }
-
+    
     void setLeft(qreal pos) { qreal diff = pos - xp; xp += diff; w -= diff; }
 
     void setRight(qreal pos) { w = pos - xp; }
@@ -226,7 +226,7 @@
         w = s.width();
         h = s.height();
     }
-
+    
     bool contains(qreal ax, qreal ay) const
     {
         return contains(QPointF(ax, ay));
@@ -286,11 +286,11 @@
     }
 
     public final void writeTo(QDataStream arg__1) {
-        qtd_QRectF_writeTo_QDataStream(&this, arg__1 is null ? null : arg__1.__nativeId);
+        qtd_QRectF_writeTo_QDataStream(&this, arg__1 is null ? null : arg__1.nativeId);
     }
 
     public final void readFrom(QDataStream arg__1) {
-        qtd_QRectF_readFrom_QDataStream(&this, arg__1 is null ? null : arg__1.__nativeId);
+        qtd_QRectF_readFrom_QDataStream(&this, arg__1 is null ? null : arg__1.nativeId);
     }
 
     public final QRectF opOr(ref QRectF r) const {
--- a/qt/d2/qt/core/QVariant.d	Thu Aug 20 19:08:32 2009 +0000
+++ b/qt/d2/qt/core/QVariant.d	Sat Aug 22 12:50:58 2009 +0000
@@ -1,7 +1,7 @@
 module qt.core.QVariant;
 
 public import qt.QGlobal;
-private import qt.QtdObject;
+private import qt.QtDObject;
 private import qt.core.QMetaType;
 
 // automatic imports-------------
@@ -27,7 +27,7 @@
 import std.string;
 
 
-public class QVariant : QtdObject
+public class QVariant : QtDObject
 {
     enum Type {
         Invalid = 0,
@@ -87,7 +87,7 @@
 
         LastType = 0xffffffff // need this so that gcc >= 3.4 allocates 32 bits for Type
     }
-
+    
 // Functions
 
     private template getMetaId()
@@ -97,7 +97,7 @@
 	    if(i <= 0)
 		i = qRegisterMetaType!(T)(name);";
     }
-
+	
     static public QVariant fromValue(T)(T obj)
     {
 	QVariant var;
@@ -125,7 +125,7 @@
 	}
 	return var;
     }
-
+    
     static public QVariant opCall(T)(T obj)
     {
 	return fromValue(obj);
@@ -138,7 +138,7 @@
 
 
     public this(QDataStream s) {
-        void* __qt_return_value = qtd_QVariant_QVariant_QDataStream(s is null ? null : s.__nativeId);
+        void* __qt_return_value = qtd_QVariant_QVariant_QDataStream(s is null ? null : s.nativeId);
         super(__qt_return_value);
     }
 
@@ -156,25 +156,25 @@
 
 
     public this(QBitArray bitarray) {
-        void* __qt_return_value = qtd_QVariant_QVariant_QBitArray(bitarray is null ? null : bitarray.__nativeId);
+        void* __qt_return_value = qtd_QVariant_QVariant_QBitArray(bitarray is null ? null : bitarray.nativeId);
         super(__qt_return_value);
     }
 
 
     public this(QByteArray bytearray) {
-        void* __qt_return_value = qtd_QVariant_QVariant_QByteArray(bytearray is null ? null : bytearray.__nativeId);
+        void* __qt_return_value = qtd_QVariant_QVariant_QByteArray(bytearray is null ? null : bytearray.nativeId);
         super(__qt_return_value);
     }
 
 
     public this(QDate date) {
-        void* __qt_return_value = qtd_QVariant_QVariant_QDate(date is null ? null : date.__nativeId);
+        void* __qt_return_value = qtd_QVariant_QVariant_QDate(date is null ? null : date.nativeId);
         super(__qt_return_value);
     }
 
 
     public this(QDateTime datetime) {
-        void* __qt_return_value = qtd_QVariant_QVariant_QDateTime(datetime is null ? null : datetime.__nativeId);
+        void* __qt_return_value = qtd_QVariant_QVariant_QDateTime(datetime is null ? null : datetime.nativeId);
         super(__qt_return_value);
     }
 
@@ -198,7 +198,7 @@
 
 
     public this(QLocale locale) {
-        void* __qt_return_value = qtd_QVariant_QVariant_QLocale(locale is null ? null : locale.__nativeId);
+        void* __qt_return_value = qtd_QVariant_QVariant_QLocale(locale is null ? null : locale.nativeId);
         super(__qt_return_value);
     }
 
@@ -228,7 +228,7 @@
 
 
     public this(QRegExp regExp) {
-        void* __qt_return_value = qtd_QVariant_QVariant_QRegExp(regExp is null ? null : regExp.__nativeId);
+        void* __qt_return_value = qtd_QVariant_QVariant_QRegExp(regExp is null ? null : regExp.nativeId);
         super(__qt_return_value);
     }
 
@@ -246,19 +246,19 @@
 
 
     public this(QTime time) {
-        void* __qt_return_value = qtd_QVariant_QVariant_QTime(time is null ? null : time.__nativeId);
+        void* __qt_return_value = qtd_QVariant_QVariant_QTime(time is null ? null : time.nativeId);
         super(__qt_return_value);
     }
 
 
     public this(QUrl url) {
-        void* __qt_return_value = qtd_QVariant_QVariant_QUrl(url is null ? null : url.__nativeId);
+        void* __qt_return_value = qtd_QVariant_QVariant_QUrl(url is null ? null : url.nativeId);
         super(__qt_return_value);
     }
 
 
     public this(QVariant other) {
-        void* __qt_return_value = qtd_QVariant_QVariant_QVariant(other is null ? null : other.__nativeId);
+        void* __qt_return_value = qtd_QVariant_QVariant_QVariant(other is null ? null : other.nativeId);
         super(__qt_return_value);
     }
 
@@ -308,7 +308,7 @@
     {
 	int i = qtd_MetatypeId(toStringz(name));
 	assert(i > 0);
-	return qtd_QVariant_canConvert(__nativeId, i);
+	return qtd_QVariant_canConvert(nativeId, i);
     }
 
     public final bool canConvert(Type)() {
@@ -353,58 +353,58 @@
 	else  static if ( is(Type == QTime) )
 	    return canConvertImpl("QTime");
 	else static if ( is(Type == uint) )
-	    return canConvertImpl("unsigned int"); // TODO:
+	    return canConvertImpl("unsigned int"); // TODO: 
 	else static if ( is(Type == ulong) )
-	    return canConvertImpl("unsigned long long"); // TODO:
+	    return canConvertImpl("unsigned long long"); // TODO: 
 	else static if ( is(Type == QUrl) )
 	    return canConvertImpl("QUrl");
 	else
 	{
 	    static if( is( Type == class ) || is( Type == interface ) )
 	    {
-		Object object = cast(Object)qtd_QVariant_data(__nativeId);
+		Object object = cast(Object)qtd_QVariant_data(nativeId);
 		if(object)
 		    return cast(Type)(object) !is null;
 		return false;
 	    }
 	    else static if (isDynamicArrayType!(Type) || isStaticArrayType!(Type) )
 	    {
-		auto array = cast(DArrayToC*)qtd_QVariant_data(__nativeId);
+		auto array = cast(DArrayToC*)qtd_QVariant_data(nativeId);
 		return cast(Type)(array.array) !is null;
 	    }
 	    else
 	    {
 		int i = qtd_MetatypeId(toStringz(typeid(Type).toString));
-		return qtd_QVariant_canConvert(__nativeId, i);
+		return qtd_QVariant_canConvert(nativeId, i);
 	    }
 	}
     }
 
     public final Type value(Type)() {
 	static if ( is(Type == QBitArray) )
-	    return toBitArra;
+	    return toBitArra; 
 	else static if ( is(Type == bool) )
-	    return toBool;
+	    return toBool; 
 	else static if ( is(Type == QByteArray) )
-	    return toByteArray;
+	    return toByteArray; 
 	else static if ( is(Type == QDate) )
-	    return toDate;
+	    return toDate; 
 	else static if ( is(Type == QDateTime) )
-	    return toDateTime;
+	    return toDateTime; 
 	else static if ( is(Type == double) )
-	    return toDouble;
+	    return toDouble; 
 	else static if ( is(Type == int) )
-	    return toInt;
+	    return toInt; 
 	else static if ( is(Type == QLine) )
-	    return toLine;
+	    return toLine; 
 	else static if ( is(Type == QLineF) )
-	    return toLineF;
+	    return toLineF; 
 	else static if ( is(Type == QLocale) )
-	    return toLocale;
+	    return toLocale; 
 	else static if ( is(Type == long) )
-	    return toLongLong;
+	    return toLongLong; 
 	else static if ( is(Type == QPoint) )
-	    return toPoint;
+	    return toPoint; 
 	else static if ( is(Type == QPointF) )
 	    return toPointF;
 	else static if ( is(Type == QRect) )
@@ -429,188 +429,194 @@
 	    return toUrl;
 	else static if( is( Type == class ) || is( Type == interface ) )
 	{
-	    Object object = cast(Object)qtd_QVariant_data(__nativeId);
+	    Object object = cast(Object)qtd_QVariant_data(nativeId);
 	    if(object)
 		return cast(Type)(object);
 	    return null;
 	}
 	else static if (isDynamicArrayType!(Type) || isStaticArrayType!(Type) )
 	{
-	    auto array = cast(DArrayToC*)qtd_QVariant_data(__nativeId);
+	    auto array = cast(DArrayToC*)qtd_QVariant_data(nativeId);
 	    return cast(Type)(array.array);
 	}
 	else
 	{
-	    return *cast(Type*)qtd_QVariant_data(__nativeId);
+	    return *cast(Type*)qtd_QVariant_data(nativeId);
 	}
     }
 
     public final void clear() {
-        qtd_QVariant_clear(__nativeId);
+        qtd_QVariant_clear(nativeId);
     }
 
     protected final bool cmp(QVariant other) {
-        return qtd_QVariant_cmp_QVariant(__nativeId, other is null ? null : other.__nativeId);
+        return qtd_QVariant_cmp_QVariant(nativeId, other is null ? null : other.nativeId);
     }
 
     protected final void create(int type, void* copy) {
-        qtd_QVariant_create_int_nativepointervoid(__nativeId, type, copy);
+        qtd_QVariant_create_int_nativepointervoid(nativeId, type, copy);
     }
 
     public final bool isNull() {
-        return qtd_QVariant_isNull(__nativeId);
+        return qtd_QVariant_isNull(nativeId);
     }
 
     public final bool isValid() {
-        return qtd_QVariant_isValid(__nativeId);
+        return qtd_QVariant_isValid(nativeId);
     }
 
     public final void load(QDataStream ds) {
-        qtd_QVariant_load_QDataStream(__nativeId, ds is null ? null : ds.__nativeId);
+        qtd_QVariant_load_QDataStream(nativeId, ds is null ? null : ds.nativeId);
     }
 
     public final void writeTo(QDataStream s) {
-        qtd_QVariant_writeTo_QDataStream(__nativeId, s is null ? null : s.__nativeId);
+        qtd_QVariant_writeTo_QDataStream(nativeId, s is null ? null : s.nativeId);
     }
 
     public final QVariant operator_assign(QVariant other) {
-        void* __qt_return_value = qtd_QVariant_operator_assign_QVariant(__nativeId, other is null ? null : other.__nativeId);
-        return new QVariant(__qt_return_value, QtdObjectFlags.nativeOwnership);
+        void* __qt_return_value = qtd_QVariant_operator_assign_QVariant(nativeId, other is null ? null : other.nativeId);
+        return new QVariant(__qt_return_value, true);
     }
 
     private final bool operator_equal(QVariant v) {
-        return qtd_QVariant_operator_equal_QVariant(__nativeId, v is null ? null : v.__nativeId);
+        return qtd_QVariant_operator_equal_QVariant(nativeId, v is null ? null : v.nativeId);
     }
 
     public final void readFrom(QDataStream s) {
-        qtd_QVariant_readFrom_QDataStream(__nativeId, s is null ? null : s.__nativeId);
+        qtd_QVariant_readFrom_QDataStream(nativeId, s is null ? null : s.nativeId);
     }
 
     public final void save(QDataStream ds) {
-        qtd_QVariant_save_QDataStream(__nativeId, ds is null ? null : ds.__nativeId);
+        qtd_QVariant_save_QDataStream(nativeId, ds is null ? null : ds.nativeId);
     }
 
     public final QBitArray toBitArray() {
-        void* __qt_return_value = qtd_QVariant_toBitArray(__nativeId);
-        return new QBitArray(__qt_return_value);
+        void* __qt_return_value = qtd_QVariant_toBitArray(nativeId);
+        return new QBitArray(__qt_return_value, false);
     }
 
     public final bool toBool() {
-        return qtd_QVariant_toBool(__nativeId);
+        return qtd_QVariant_toBool(nativeId);
     }
 
     public final QByteArray toByteArray() {
-        void* __qt_return_value = qtd_QVariant_toByteArray(__nativeId);
-        return new QByteArray(__qt_return_value);
+        void* __qt_return_value = qtd_QVariant_toByteArray(nativeId);
+        return new QByteArray(__qt_return_value, false);
     }
 
     public final QDate toDate() {
-        void* __qt_return_value = qtd_QVariant_toDate(__nativeId);
-        return new QDate(__qt_return_value);
+        void* __qt_return_value = qtd_QVariant_toDate(nativeId);
+        return new QDate(__qt_return_value, false);
     }
 
     public final QDateTime toDateTime() {
-        void* __qt_return_value = qtd_QVariant_toDateTime(__nativeId);
-        return new QDateTime(__qt_return_value);
+        void* __qt_return_value = qtd_QVariant_toDateTime(nativeId);
+        return new QDateTime(__qt_return_value, false);
     }
 
     public final double toDouble(bool* ok = null) {
-        return qtd_QVariant_toDouble_nativepointerbool(__nativeId, ok);
+        return qtd_QVariant_toDouble_nativepointerbool(nativeId, ok);
     }
 
     public final int toInt(bool* ok = null) {
-        return qtd_QVariant_toInt_nativepointerbool(__nativeId, ok);
+        return qtd_QVariant_toInt_nativepointerbool(nativeId, ok);
     }
 
     public final QLine toLine() {
-        return qtd_QVariant_toLine(__nativeId);
+        return qtd_QVariant_toLine(nativeId);
     }
 
     public final QLineF toLineF() {
-        return qtd_QVariant_toLineF(__nativeId);
+        return qtd_QVariant_toLineF(nativeId);
     }
 
     public final QLocale toLocale() {
-        void* __qt_return_value = qtd_QVariant_toLocale(__nativeId);
-        return new QLocale(__qt_return_value);
+        void* __qt_return_value = qtd_QVariant_toLocale(nativeId);
+        return new QLocale(__qt_return_value, false);
     }
 
     public final long toLongLong(bool* ok = null) {
-        return qtd_QVariant_toLongLong_nativepointerbool(__nativeId, ok);
+        return qtd_QVariant_toLongLong_nativepointerbool(nativeId, ok);
     }
 
     public final QPoint toPoint() {
-        return qtd_QVariant_toPoint(__nativeId);
+        return qtd_QVariant_toPoint(nativeId);
     }
 
     public final QPointF toPointF() {
-        return qtd_QVariant_toPointF(__nativeId);
+        return qtd_QVariant_toPointF(nativeId);
     }
 
     public final QRect toRect() {
-        return qtd_QVariant_toRect(__nativeId);
+        return qtd_QVariant_toRect(nativeId);
     }
 
     public final QRectF toRectF() {
-        return qtd_QVariant_toRectF(__nativeId);
+        return qtd_QVariant_toRectF(nativeId);
     }
 
     public final QRegExp toRegExp() {
-        void* __qt_return_value = qtd_QVariant_toRegExp(__nativeId);
-        return new QRegExp(__qt_return_value);
+        void* __qt_return_value = qtd_QVariant_toRegExp(nativeId);
+        return new QRegExp(__qt_return_value, false);
     }
 
     public final QSize toSize() {
-        return qtd_QVariant_toSize(__nativeId);
+        return qtd_QVariant_toSize(nativeId);
     }
 
     public final QSizeF toSizeF() {
-        return qtd_QVariant_toSizeF(__nativeId);
+        return qtd_QVariant_toSizeF(nativeId);
     }
 
     public final string toString() {
         string res;
-        qtd_QVariant_toString(__nativeId, &res);
+        qtd_QVariant_toString(nativeId, &res);
         return res;
     }
 
     public final QTime toTime() {
-        void* __qt_return_value = qtd_QVariant_toTime(__nativeId);
-        return new QTime(__qt_return_value);
+        void* __qt_return_value = qtd_QVariant_toTime(nativeId);
+        return new QTime(__qt_return_value, false);
     }
 
     public final uint toUInt(bool* ok = null) {
-        return qtd_QVariant_toUInt_nativepointerbool(__nativeId, ok);
+        return qtd_QVariant_toUInt_nativepointerbool(nativeId, ok);
     }
 
     public final ulong toULongLong(bool* ok = null) {
-        return qtd_QVariant_toULongLong_nativepointerbool(__nativeId, ok);
+        return qtd_QVariant_toULongLong_nativepointerbool(nativeId, ok);
     }
 
     public final QUrl toUrl() {
-        void* __qt_return_value = qtd_QVariant_toUrl(__nativeId);
-        return new QUrl(__qt_return_value);
+        void* __qt_return_value = qtd_QVariant_toUrl(nativeId);
+        return new QUrl(__qt_return_value, false);
     }
 
     public final char* typeName() {
-        return qtd_QVariant_typeName(__nativeId);
+        return qtd_QVariant_typeName(nativeId);
     }
-
+    
     public final Type type() {
-        return cast(Type)qtd_QVariant_type(__nativeId);
+        return cast(Type)qtd_QVariant_type(nativeId);
     }
 
     public final int userType() {
-        return qtd_QVariant_userType(__nativeId);
+        return qtd_QVariant_userType(nativeId);
     }
 // Field accessors
 
-    public this(void* native_id, QtdObjectFlags flags = QtdObjectFlags.none) {
-        super(native_id, flags);
+    public this(void* native_id, bool no_real_delete = false) {
+        super(native_id, no_real_delete);
     }
 
-    protected override void __deleteNative() {
-        qtd_QVariant_destructor(__nativeId);
+
+    ~this() {
+        if(!__no_real_delete)
+            __free_native_resources();
+    }
+
+    protected void __free_native_resources() {
+        qtd_QVariant_destructor(nativeId());
     }
 
 // Injected code in class
--- a/qt/d2/qt/qtd/Str.d	Thu Aug 20 19:08:32 2009 +0000
+++ b/qt/d2/qt/qtd/Str.d	Sat Aug 22 12:50:58 2009 +0000
@@ -36,7 +36,7 @@
         argv[argc++] = cast(char*)(p.dup~'\0');
     }
     argv[argc] = null;
-
+        
     return argv;
 }
 
@@ -45,11 +45,19 @@
     return s ? s[0 .. strlen(s)].idup : cast(string)null;
 }
 
-
-extern(C) void qtd_toUtf8(wchar* arr, uint size, string* str)
+version(Windows)
 {
-    *str = toUTF8(arr[0..size]);
+    export extern(C) void _d_toUtf8(wchar* arr, uint size, string* str)
+    {
+        *str = toUTF8(arr[0..size]);
+    }
+}
+else
+{
+    extern(C) void _d_toUtf8(wchar* arr, uint size, string* str)
+    {
+        *str = toUTF8(arr[0..size]);
+    }
 }
 
 
-
--- a/qt/qtd/Traits.d	Thu Aug 20 19:08:32 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-module qt.qtd.Traits;
-
-version (D_Version2)
-{
-    public import std.traits;
-}
-else
-{
-    public import tango.core.Traits : BaseTypeTuple = BaseTypeTupleOf;
-}