Page 1 of 1

Why `TRVStyleTemplate(nil).ApplyToTextStyle` works??

Posted: Thu Jun 23, 2022 3:49 pm
by edwinyzh
I've found many occurrences of

Code: Select all

TRVStyleTemplate(nil).ApplyToTextStyle
in the TRichView codebase, but it puzzles me - why casting nil as TRVStyleTemplate works??

Anyone can tell me? Thanks.

Re: Why `TRVStyleTemplate(nil).ApplyToTextStyle` works??

Posted: Fri Jun 24, 2022 9:30 am
by Sergey Tkachenko
TRVStyleTemplate.ApplyToTextStyle was designed to work correctly if called for nil objects.
The code inside this method checks if Self = nil, and if True, it unassigns the text style (from the parameter) from a text style template.

Re: Why `TRVStyleTemplate(nil).ApplyToTextStyle` works??

Posted: Fri Jun 24, 2022 1:21 pm
by edwinyzh
Oh I see, thanks!