Getting string value from Text field: my 2.5 code stopped working

Matthew Jew mjew at icnc.com
Thu May 15 18:17:49 CDT 2008


On May 14, 2008, at 11:34 AM, Ruslan Zasukhin wrote:

> On 5/14/08 8:44 PM, "Matthew Jew" <mjew at icnc.com> wrote:
>
> Hi Matthew,
>
>> (This is another version 2.5.8 to 3.5.2 issue).
>>
>> I have for years been using this code to retrieve my long text values
>> from my TextFields:
>>
>> I_FldBlob_Ptr pBlobField = dynamic_cast< I_FldBlob* >
>> (aHTMLTemplateTable->valueText.get());
>
>> dataLength = pBlobField->get_DataSize();
>> aMutableData = [[NSMutableData alloc] initWithLength:dataLength];
>>
>> Const_I_Value_Ptr myStringValue = aHTMLTemplateTable->valueText-
>>> get_Value();
>> unsigned long myStringLength = myStringValue->get_Length();
>> myStringValue->get_String( (unichar *) [aMutableData mutableBytes],
>> dataLength );
>>
>> returnValue = [NSString stringWithCharacters: (const unichar *)
>> [aMutableData mutableBytes] length:myStringLength ];
>>
>>
>> Although this compiles, now my application gets a EXC_BAD_ACCESS
>> error on the get_DataSize() call.
>>
>> Is there a new way to do this?
>
> Please try this line
>
>  I_FldBlob_Ptr pBlobField = QI( aHTMLTemplateTable->valueText,  
> I_FldBlob );
>
>
> QI is short cut for QueryInterface(), method good known in the COM.
>
> This is kind of dynamic_cast<>, but based on COM mechanims.
> We do not use try COM, we use its ideas
>
>
> -- 
> Best regards,
>
> Ruslan Zasukhin
> VP Engineering and New Technology
> Paradigma Software, Inc
>

Ruslan,

The code you suggested works.

Thank you very much.

- Matthew




More information about the Valentina mailing list