Exemple #1
0
MComponent* MProject::attachComponent( WFileName& filename )
{
    MComponent* comp = NULL;
    WObjectFile ot;
    if( ot.open( filename, OStyleReadB ) ) {
        _recursing = true;
        if( ot.version() < 34 ) {
            ot.readObject( this );
            comp = (MComponent*)ot.readObject();
            comp->setRelFilename( filename );
            _components.add( comp );
            setDirty();
        } else {
            char ident[sizeof( _targetIdent ) + 1];
            ot.readObject( ident, sizeof( ident ) - 1 );
            if( !streq( ident, _targetIdent ) ) {
                //bad file format
            } else {
                ot.readObject( this );
                comp = (MComponent*)ot.readObject();
                comp->setRelFilename( filename );
                _components.add( comp );
                setDirty();
            }
        }
        _recursing = false;
        ot.close();
    }
    return( comp );
}