On 02/14/2018 03:04 AM, Jürgen Spitzmüller wrote: > Am Montag, den 12.02.2018, 16:31 -0500 schrieb Richard Heck: >>> src/frontends/qt4/GuiDocument.cpp | 6 ++++++ >>> 1 files changed, 6 insertions(+), 0 deletions(-) >>> >>> diff --git a/src/frontends/qt4/GuiDocument.cpp >>> b/src/frontends/qt4/GuiDocument.cpp >>> index 85318bc..8149b50 100644 >>> --- a/src/frontends/qt4/GuiDocument.cpp >>> +++ b/src/frontends/qt4/GuiDocument.cpp >>> @@ -4007,6 +4007,12 @@ bool GuiDocument::isBiblatex() const >>> biblioModule->citeEngineCO->itemData( >>> biblioModule->citeEngineCO- >>>> currentIndex()).toString(); >>> >>> + // this can happen if the cite engine is unknown, which >>> can happen >>> + // if one is using a file that came from someone else, >>> etc. in that >>> + // case, we crash if we proceed. >>> + if (engine.isEmpty()) >>> + return false; >>> + >>> return theCiteEnginesList[fromqstr(engine)]- >>>> getCiteFramework() == "biblatex"; >>> } >>> > 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. > 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. Richard