Page MenuHome
Paste P465

Forward compatibility after D113
ActivePublic

Authored by Alexander Romanov (a.romanov) on Apr 14 2017, 7:54 PM.
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index c55b426..4549c12 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2079,6 +2079,13 @@ static void IDP_DirectLinkGroup(IDProperty *prop, int switch_endian, FileData *f
static void IDP_DirectLinkProperty(IDProperty *prop, int switch_endian, FileData *fd)
{
switch (prop->type) {
+ case IDP_INT:
+ /* hack for keeping forward compatibility after D113 */
+ if (!(prop->flag & IDP_FLAG_ID))
+ break;
+ prop->type = IDP_ID;
+ prop->flag &= ~IDP_FLAG_ID;
+ break;
case IDP_GROUP:
IDP_DirectLinkGroup(prop, switch_endian, fd);
break;
@@ -2139,6 +2146,12 @@ static void IDP_LibLinkProperty(IDProperty *prop, FileData *fd)
return;
switch (prop->type) {
+ case IDP_INT:
+ /* hack for keeping forward compatibility after D113 */
+ if (!(prop->flag & IDP_FLAG_ID))
+ break;
+ prop->type = IDP_ID;
+ prop->flag &= ~IDP_FLAG_ID;
case IDP_ID: /* PointerProperty */
{
void *newaddr = newlibadr_us(fd, NULL, IDP_Id(prop));
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 57be237..1c24e37 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -665,7 +665,23 @@ void IDP_WriteProperty_OnlyData(const IDProperty *prop, void *wd)
void IDP_WriteProperty(const IDProperty *prop, void *wd)
{
+ bool handle_id = prop->type == IDP_ID;
+ IDProperty *p = (IDProperty *)prop;
+
+ /* hack for keeping forward compatibility after D113
+ * writing IDP_ID as IPD_INT
+ */
+ if (handle_id) {
+ p->flag |= IDP_FLAG_ID;
+ p->type = IDP_INT;
+ }
+
writestruct(wd, DATA, IDProperty, 1, prop);
+
+ if (handle_id) {
+ p->flag &= ~IDP_FLAG_ID;
+ p->type = IDP_ID;
+ }
IDP_WriteProperty_OnlyData(prop, wd);
}
diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h
index da0f505..ac3e99b 100644
--- a/source/blender/makesdna/DNA_ID.h
+++ b/source/blender/makesdna/DNA_ID.h
@@ -98,6 +98,7 @@ enum {
/*->flag*/
enum {
+ IDP_FLAG_ID = 1 << 0, /* Hack for solving forward compatibility issue */
IDP_FLAG_GHOST = 1 << 7, /* this means the property is set but RNA will return false when checking
* 'RNA_property_is_set', currently this is a runtime flag */
};