[ Home | CW Bug Reports | Mail ]

LModelProperty::HandleSetData()で file propertyが setできない
Subject: BUG -- PP2.0 LModelProperty::HandleSetData() and file property
 
---------------------------------------------------------------------------
METROWERKS PRODUCT AND USAGE SECTION
 
Product name :            [ CodeWarrior Professional for Mac ]
Product version :         [ Pro 5 ]
Component name :          [ PowerPlant 2.0 ]
Generating:               [ Mac OS 68K / Mac OS PowerPC ]
Purpose:                  [ application ]
 
---------------------------------------------------------------------------
 
BUG DESCRIPTION SECTION
 
Reason for this report:   [ incomplete program feature ]
Bug severity:             [ executes incorrectly ]
Reproducibility:          [ always ]
Problem summary:
 
LModelProperty::HandleSetData() should wrap the typeObjectSpecifier
resolution code (added at PowerPlant 2.0) with try block, and ignore
errors. You can't set any file property without this.
 
The AppleScript component generates an AppleEvent (2) in regard to
the script (1).
 
(1) AppleScript
tell application "MgrepApp"
    set searchTarget of window 1 to file "Part1:Telecom:"
end tell
 
(2) AppleEvent captured by "Capture AE"
Process("MgrepApp").SendAE
    "core,setd,'----':obj {form:prop, want:type(prop), seld:type(sFol),
    from:obj {form:indx, want:type(cwin), seld:1, from:'null'()}},
>>  data:obj {form:name, want:type(file), seld:"Part1:Telecom:", 
from:'null'()}"
 
As you can see, file property is represented as a named element of the
default model. System's ObjectSpecifier -> FSSpec coercion handler
does the conversion to get a real FSSpec. It has worked well until
PowerPlant 1.9.3.
 
PowerPlant 2.0 erroneously breaks this code flow at the
LModelDirector::Resolve()'s failure.
 
void
LModelProperty::HandleSetData(
    const AppleEvent&   inAppleEvent,
    AppleEvent&         outAEReply)
{
    StAEDescriptor  value;          // Extract value to which to set
    value.GetParamDesc(inAppleEvent, keyAEData, typeWildCard);
 
    //-------------------------------------------------------------------
    try {
    //-------------------------------------------------------------------
 
    if (value.DescriptorType() == typeObjectSpecifier) {
 
            // "value" is an object specifier. Resolve it to a LModelObject
 
        StAEDescriptor  tokenD;
        OSErr   err = LModelDirector::Resolve(value, tokenD);
        ThrowIfOSErr_(err);
 
        LModelObject*   refObject = GetModelFromToken(tokenD);
 
        if (refObject->GetModelKind() == cProperty) {
 
                // ospec resolved to a Property object. Change "value"
                // to the data for that Property object.
 
            LModelProperty* refProperty = dynamic_cast<LModelProperty*>(refObject);
 
            StAEDescriptor  getDataEvent;
            UAppleEventsMgr::MakeAppleEvent(kAECoreSuite, kAEGetData, getDataEvent);
 
            value.Dispose();            // We are going to change the value
            refProperty->HandleGetData(getDataEvent, value, ae_GetData);
 
        } else {
 
                // ospec isn't a Property. Change "value" to the token for
                // this object so that SetAEProperty() doesn't have to
                // resolve the ospec again. You can extract the underlying
                // LModelObject* by calling GetModelFromToken().
 
            value = tokenD;
        }
    }
 
    //-------------------------------------------------------------------
    }catch(...) {
    }
    //-------------------------------------------------------------------
 
    UAppleEventsMgr::CheckForMissedParams(inAppleEvent);
 
    GetSuperModel()->SetAEProperty(mPropertyID, value, outAEReply);
}


この Pageは MacOS X + Radio UserLand で作っています。