diff --git a/include/osgDB/PropertyInterface b/include/osgDB/PropertyInterface index d8d94ea5c..581819910 100644 --- a/include/osgDB/PropertyInterface +++ b/include/osgDB/PropertyInterface @@ -268,7 +268,9 @@ inline bool PropertyInterface::getProperty(const osg::Object* object, const std: template<> inline bool PropertyInterface::setProperty(osg::Object* object, const std::string& propertyName, const ObjectPtr& value) { - if (copyPropertyObjectToObject(object, propertyName, &value, sizeof(ObjectPtr), getTypeEnum())) return true; + osgDB::BaseSerializer::Type type = dynamic_cast(value) ? osgDB::BaseSerializer::RW_IMAGE : getTypeEnum(); + // osgDB::BaseSerializer::Type type = getTypeEnum(); + if (copyPropertyObjectToObject(object, propertyName, &value, sizeof(ObjectPtr), type)) return true; else { // fallback to using user data to store property data diff --git a/src/osgDB/PropertyInterface.cpp b/src/osgDB/PropertyInterface.cpp index 4d93f096f..50374e0a1 100644 --- a/src/osgDB/PropertyInterface.cpp +++ b/src/osgDB/PropertyInterface.cpp @@ -264,6 +264,8 @@ bool PropertyInterface::areTypesCompatible(osgDB::BaseSerializer::Type lhs, osgD if (lhs==osgDB::BaseSerializer::RW_ENUM) lhs = osgDB::BaseSerializer::RW_INT; if (rhs==osgDB::BaseSerializer::RW_ENUM) rhs = osgDB::BaseSerializer::RW_INT; + if (lhs==osgDB::BaseSerializer::RW_IMAGE) lhs = osgDB::BaseSerializer::RW_OBJECT; + return lhs==rhs; } @@ -392,7 +394,7 @@ bool PropertyInterface::copyPropertyObjectFromObject(const osg::Object* object, osgDB::BaseSerializer* serializer = getSerializer(object, propertyName, sourceType); if (serializer) { - if (areTypesCompatible(valueType, sourceType)) + if (areTypesCompatible(sourceType, valueType)) { return serializer->get(*object, valuePtr); }