[LyX/master] Advaced search: check for toString() before using it. (#12783)
Kornel Benko
kornel at lyx.org
Fri May 19 08:41:22 UTC 2023
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.
Kornel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: Digitale Signatur von OpenPGP
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20230519/d8982515/attachment-0001.asc>
More information about the lyx-devel
mailing list