[LyX/master] Advaced search: check for toString() before using it. (#12783)

Richard Kimberly Heck rikiheck at gmail.com
Fri May 19 15:31:26 UTC 2023


On 5/19/23 04:41, Kornel Benko wrote:
> Am Fri, 19 May 2023 00:09:09 -0400
> schrieb Richard Kimberly Heck <rikiheck at gmail.com>:
>
>> On 5/18/23 11:02, Kornel Benko wrote:
>>> commit f13808939b9ae6d8d467538d17157a87e8a1a37c
>>> Author: Kornel Benko <kornel at lyx.org>
>>> Date:   Thu May 18 18:07:40 2023 +0200
>>>
>>>       Advaced search: check for toString() before using it.
>>>       (#12783)
>>>
>>> diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
>>> index b8819fd..fed5a74 100644
>>> --- a/src/Paragraph.cpp
>>> +++ b/src/Paragraph.cpp
>>> @@ -4314,7 +4314,7 @@ docstring Paragraph::asString(pos_type beg, pos_type end, int
>>> options, const Out else if (c == META_INSET && (options & AS_STR_INSETS)) {
>>>    			if (c == META_INSET && (options & AS_STR_PLAINTEXT)) {
>>>    				LASSERT(runparams != nullptr, return docstring());
>>> -				if (runparams->find_effective())
>>> +				if (runparams->find_effective() &&
>>> getInset(i)->hasToString()) getInset(i)->toString(os);
>>>    				else
>>>    					getInset(i)->plaintext(os, *runparams);
>> I know this will be an annoying suggestion after all that work, but what
>> about:
>>
>> if (runparams->find_effective) {
>>       string str = getInset(i)->toString(os);
>>       if (str.empty())
>>           str = getInset(i)->plaintext(os, *runaparms);
>> }
>>
>> ? Then no need for the new method.
>>
>> Riki
>>
>>
> I was unaware that getInset(i)->toString(os) returns a string (declared as void)
> Maybe it would work with
> 	if (os.str().empty())
> but that may not work if 'os' already had some data.

Oh, sorry, you're right.

Riki




More information about the lyx-devel mailing list