~ubuntu-branches/ubuntu/oneiric/kdesdk/oneiric-proposed

« back to all changes in this revision

Viewing changes to okteta/kasten/controllers/view/structures/datatypes/dynamiclengtharraydatainformation.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Kolberg
  • Date: 2011-09-08 11:38:43 UTC
  • mfrom: (0.4.11)
  • Revision ID: package-import@ubuntu.com-20110908113843-fjks2jv4d9o9g7pk
Tags: 4:4.7.1-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
}
71
71
int DynamicLengthArrayDataInformation::calculateLength()
72
72
{
73
 
    if (!mParent)
 
73
    if (!mParent || mParent->isTopLevel())
74
74
    {
75
75
        kWarning() << "dynamic length array without parent ->"
76
76
            " length will always be 0";
77
77
        return 0;
78
78
    }
79
 
    QList<const DataInformation*> refs = findChildrenWithName(mLengthString, this);
80
 
    if (refs.length() == 0)
81
 
    {
82
 
        kDebug()
83
 
            << "referenced size field not found";
84
 
        return 0;
85
 
    }
86
 
    for (int i = 0; i < refs.length(); ++i)
87
 
    {
88
 
        const DataInformation* data = refs.at(i);
89
 
        const PrimitiveDataInformation* prim =
90
 
                dynamic_cast<const PrimitiveDataInformation*> (data);
91
 
        if (prim)
92
 
        {
93
 
            if (!prim->wasAbleToRead())
94
 
            {
95
 
                kDebug()
96
 
                    << "primitive type is not valid";
97
 
                continue;
98
 
            }
99
 
            else
100
 
            {
101
 
                return prim->value().ulongValue;
102
 
            }
103
 
        }
 
79
    QPair<DataInformation*, QString> val =
 
80
        static_cast<DataInformation*>(mParent)->findChildForDynamicArrayLength(mLengthString, row());
 
81
    const DataInformation* data = val.first;
 
82
    const QString path = QLatin1String("this.parent.") + val.second; //this is so I can finally remove this class soon
 
83
    const PrimitiveDataInformation* prim = dynamic_cast<const PrimitiveDataInformation*>(data);
 
84
    if (!prim)
 
85
    {
 
86
        kDebug() << "referenced value (" << mLengthString << ") was not a primitive value";
 
87
    }
 
88
    else if (!prim->wasAbleToRead())
 
89
    {
 
90
        kDebug() << "was not able to read new array length for " << name()
 
91
            << "referenced value (" << mLengthString << ") was not valid";
 
92
    }
 
93
    else
 
94
    {
 
95
        return prim->value().ulongValue;
104
96
    }
105
97
    return 0;
106
98
}