On 02/14/2018 11:12 AM, Jürgen Spitzmüller wrote:
> Am Mittwoch, den 14.02.2018, 10:11 -0500 schrieb Richard Heck:
>>> I wonder how that happens. 
>> LyXCiteEngine const * CiteEnginesList::operator[](string const & str)
>> const
>> {
>>     LyXCiteEnginesList::const_iterator it = englist_.begin();
>>     for (; it != englist_.end(); ++it)
>>         if (it->getID() == str) {
>>             LyXCiteEngine const & eng = *it;
>>             return ŋ
>>         }
>>     return 0;
>> }
>> The crucial point seems to be that we are in a const function, so we
>> return a null pointer. Boom.
> It didn't mean technically. That's clear. I mean how the empty string
> comes into the LyX file. Any sane LyX 2.3 document should have _some_
> cite engine set.

Oh, sorry. It's not empty in the LyX file. The value is coming from the
bibliography part of the GuiDocument:

    QString const engine =

This index was supposed to be set from the engine read from the LyX
file. But that engine doesn't exist, so it didn't get set properly.
Probably that needs to be taken into account.

>>> Anyway, would be the following more safe (if
>>> we have an unknown non-empty string)?
>>>        return theCiteEnginesList[fromqstr(engine)]
>>>     && theCiteEnginesList[fromqstr(engine)]->getCiteFramework()
>>>        == "biblatex";
>>> This should also cover the empty case.
>> Maybe what would be best is to create and use
>> CiteEnginesList::hasEngine(const & string). Then add an assertion to the 
>> function quoted above. This is how things are done in other places.
> Maybe, but for now, isn't a check whether the pointer is null better
> than checking just the string emptiness?

In light of what was said above, this is equivalent at this point in the
code. But there seem to be other places in GuiDocument that we rely upon
the pointer not to be null, and we need also to do something about
those. Also at BufferParams::useBiblatex().

I wonder if what we really need to do here is add the 'unknown' cite
engine the way we do unknown layouts. Otherwise, if, say, the font is
modified in Document>Settings, then I am guessing we won't save the
document with the same engine it had before: It isn't known there. That
would mean we needed some other way to tell if the engine was 'real',
rather than testing the pointer, but we do all of this with 'unknown'


Reply via email to