Klemens Loschy wrote: > > http://qt.gitorious.org/qt-jambi/qtpropertybrowser-binding. But some > problems do exist: methods like > > /QtBrowserItem QtAbstractPropertyBrowser.currentItem(); > QtProperty QtBrowserItem.property();/ > > always create new Java Objects instead of returning existing ones. I > tried to move the ownership to c++ (using <define ownership> in the > typesystem.xml), but this had no effect. Maybe i did not modify all > required methods... >
Hi, This is a limitation in Qt Jambi. Usually when Qt Jambi tries to pass an non-QObject object from C++ to Java, it will look up the pointer in a hash table and connect the pointer to a Java object. However, when an object has been created natively by non-generated C++ code and it is not a subclass of QObject, Qt Jambi has no control over it. Specifically, it cannot control when the object is deleted, since it does not control the object's destructor. This means that the object could be removed without our knowing, and the address in memory could be reused. Since we could not detect that the object was deleted, we had no way of removing the link between the pointer and the Java object in the hash table. The result would be that arbitrary Java objects would be linked to native objects of incompatible types, and you would have severe crashes. To avoid this, Qt Jambi will always create a fresh Java object when passing an object with these conditions to Java. This means that you cannot rely on the identity comparison of Qt Jambi objects to see if they refer to the same data. If you want to compare the identity of the underlying native objects, you can compare the nativeId() values of the objects. So rather than: if (object1 == object2) ... you can do a if (object1.nativeId() == object2.nativeId()) ... -- Eskil _______________________________________________ Qt-jambi-interest mailing list Qt-jambi-interest@trolltech.com http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest