Commit 381339e5 authored by claes's avatar claes

Internal references wasn't updated correctly at cast

parent a6c399bf
/*
* Proview $Id: wb_cdef.cpp,v 1.16 2007-09-19 15:12:16 claes Exp $
* Proview $Id: wb_cdef.cpp,v 1.17 2008-03-19 07:31:09 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -22,6 +22,7 @@
#include "wb_cdef.h"
#include "wb_cdrep.h"
#include "wb_object.h"
#include "wb_attribute.h"
wb_cdef::wb_cdef() : wb_status(LDH__NOCLASS), m_cdrep(0)
{
......@@ -167,6 +168,12 @@ void wb_cdef::templateBody( pwr_tStatus *sts, pwr_eBix bix, void *p, pwr_tOid oi
m_cdrep->templateBody( sts, bix, p, oid);
}
void wb_cdef::attrTemplateBody( pwr_tStatus *sts, pwr_eBix bix, void *p, wb_attribute& a)
{
check();
m_cdrep->attrTemplateBody( sts, bix, p, a);
}
size_t wb_cdef::size( pwr_eBix bix)
{
check();
......
/*
* Proview $Id: wb_cdef.h,v 1.16 2005-09-06 10:43:31 claes Exp $
* Proview $Id: wb_cdef.h,v 1.17 2008-03-19 07:31:09 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -30,6 +30,7 @@ class wb_cdrep;
class wb_mvrep;
class wb_object;
class wb_orep;
class wb_attribute;
class wb_cdef : public wb_status
{
......@@ -65,6 +66,7 @@ public:
wb_bdef bdef(wb_name bname);
void templateBody( pwr_tStatus *sts, pwr_eBix bix, void *p, pwr_tOid oid);
void attrTemplateBody( pwr_tStatus *sts, pwr_eBix bix, void *p, wb_attribute& a);
wb_object classBody( const char *bname);
wb_cdef super();
......
/*
* Proview $Id: wb_cdrep.cpp,v 1.34 2007-11-06 16:56:23 claes Exp $
* Proview $Id: wb_cdrep.cpp,v 1.35 2008-03-19 07:31:09 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -27,6 +27,7 @@
#include "wb_orepdbs.h"
#include "wb_bdrep.h"
#include "wb_adrep.h"
#include "wb_attribute.h"
extern "C" {
#include "rt_conv.h"
}
......@@ -267,6 +268,57 @@ void wb_cdrep::templateBody( pwr_tStatus *sts, pwr_eBix bix, void *p, pwr_tOid o
orep->unref();
}
void wb_cdrep::attrTemplateBody( pwr_tStatus *sts, pwr_eBix bix, void *p, wb_attribute& a)
{
pwr_tStatus status;
pwr_tAttrRef aref;
aref = a.aref();
if ( aref.Flags.b.Object) {
templateBody( sts, bix, p, a.aoid());
return;
}
// Search for template in localWb
wb_vrep *localwb = m_orep->vrep()->erep()->volume( &status, ldh_cWBVolLocal);
if ( ODD(status)) {
char name[120];
sprintf( name, "Templates-%s", m_orep->name());
wb_name n = wb_name(name);
wb_orep *templ = localwb->object( &status, n);
if ( ODD(status) && templ->cid() == cid()) {
templ->ref();
localwb->readBody( &status, templ, bix, p);
if ( ODD(status)) {
if ( cdh_ObjidIsNotNull(a.aoid()))
updateTemplateSubClass( a.adrep(), (char *)p, a.aoid(), templ->oid(), aref.Offset);
*sts = LDH__SUCCESS;
templ->unref();
return;
}
templ->unref();
}
}
// Get objid for template object
pwr_tOid oid;
int cix = cdh_oixToCix( m_orep->oid().oix);
oid.vid = m_orep->oid().vid;
oid.oix = cdh_cixToOix( cix, pwr_eBix_template, 0);
wb_orep *orep = m_orep->vrep()->object( sts, oid);
if ( EVEN(*sts)) return;
m_orep->vrep()->readBody( sts, orep, bix, p);
if ( cdh_ObjidIsNotNull(oid)) {
updateTemplateSubClass( a.adrep(), (char *)p, a.aoid(), oid, aref.Offset);
}
// Delete
orep->ref();
orep->unref();
}
pwr_mClassDef wb_cdrep::flags()
{
pwr_sClassDef *classdef;
......@@ -818,7 +870,7 @@ void wb_cdrep::convertObject( wb_merep *merep, void *rbody, void *dbody,
void wb_cdrep::updateTemplateSubClass( wb_adrep *subattr, char *body, pwr_tOid oid,
pwr_tOid toid)
pwr_tOid toid, int aoffs)
{
pwr_tStatus sts;
pwr_tCid cid = subattr->subClass();
......@@ -835,7 +887,7 @@ void wb_cdrep::updateTemplateSubClass( wb_adrep *subattr, char *body, pwr_tOid o
int elements = adrep->isArray() ? adrep->nElement() : 1;
if ( adrep->isClass()) {
updateTemplateSubClass( adrep, body + i * subattr->size() / subattr_elements + adrep->offset(),
oid, toid);
oid, toid, aoffs);
}
else {
switch ( adrep->type()) {
......@@ -853,8 +905,10 @@ void wb_cdrep::updateTemplateSubClass( wb_adrep *subattr, char *body, pwr_tOid o
pwr_sAttrRef *arp = (pwr_sAttrRef *)(body + i * subattr->size() / subattr_elements +
adrep->offset());
for ( int j = 0; j < elements; j++) {
if ( cdh_ObjidIsEqual( arp->Objid, toid))
if ( cdh_ObjidIsEqual( arp->Objid, toid)) {
arp->Objid = oid;
arp->Offset += aoffs;
}
arp++;
}
break;
......@@ -885,7 +939,7 @@ void wb_cdrep::updateTemplate( pwr_eBix bix, void *b, pwr_tOid oid, pwr_tOid toi
while ( ODD(sts)) {
int elements = adrep->isArray() ? adrep->nElement() : 1;
if ( adrep->isClass()) {
updateTemplateSubClass( adrep, body + adrep->offset(), oid, toid);
updateTemplateSubClass( adrep, body + adrep->offset(), oid, toid, 0);
}
else {
switch ( adrep->type()) {
......
/*
* Proview $Id: wb_cdrep.h,v 1.22 2006-05-24 15:00:41 claes Exp $
* Proview $Id: wb_cdrep.h,v 1.23 2008-03-19 07:31:09 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -31,6 +31,7 @@ class wb_mvrep;
class wb_orep;
class wb_orepdbs;
class wb_merep;
class wb_attribute;
class wb_cdrep
{
......@@ -69,6 +70,7 @@ public:
wb_cdrep* super( pwr_tStatus *sts);
void templateBody( pwr_tStatus *sts, pwr_eBix bix, void *p, pwr_tOid oid);
void attrTemplateBody( pwr_tStatus *sts, pwr_eBix bix, void *p, wb_attribute& a);
void dbCallBack( pwr_tStatus *sts, ldh_eDbCallBack cb, char **methodName,
pwr_sDbCallBack **o);
wb_orep *menu( pwr_tStatus *sts, void **o);
......@@ -85,7 +87,7 @@ public:
void **cnv_rbody, void **cnv_dbody);
void updateTemplateSubClass( wb_adrep *subattr, char *body, pwr_tOid oid,
pwr_tOid toid);
pwr_tOid toid, int aoffs);
void updateTemplate( pwr_eBix bix, void *b, pwr_tOid oid, pwr_tOid toid);
pwr_tStatus sts() { return m_sts;}
ldh_eVolRep vtype() const;
......
/*
* Proview $Id: wb_session.cpp,v 1.25 2008-02-27 06:31:57 claes Exp $
* Proview $Id: wb_session.cpp,v 1.26 2008-03-19 07:31:09 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -971,7 +971,7 @@ bool wb_session::castAttribute( pwr_sAttrRef *arp, pwr_tCid cid)
}
void *body = calloc( 1, c.size( pwr_eBix_rt));
c.templateBody( &m_sts, pwr_eBix_rt, body, arp->Objid);
c.attrTemplateBody( &m_sts, pwr_eBix_rt, body, a);
try {
writeAttribute( a, body);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment