|
 |
On 7/15/21 4:56 PM, clipka wrote:
> Am 15.07.2021 um 13:29 schrieb William F Pokorny:
>
>> Looks like a problem with spline{} block parsing when passing a spline
>> id. The current Parse_Spline() code expects the spline type token to
>> exist otherwise it assumes the intent was a linear spline.
>>
>> A fix is to add some dynamic_cast 'type checking' to:
>>
>> GenericSpline *Parser::Parse_Spline()
>
> Fortunately, there's a more elegant solution: The `GenericSpline` class
> has a virtual member function, `Clone()`, that is implemented by each
> subclass to return a newly constructed copy of whatever the actual type
> of the object is.
>
> So the code in question can remain as simple as:
>
> if (!New)
> {
> if (Old)
> New = Old->Clone();
> else
> New = new LinearSpline();
> }
>
> Will you do the honors, or shall I?
Please go ahead.
I'll be updating my own pile of code to your cleaner fix - thank you.
Bill P.
Post a reply to this message
|
 |