[sword-devel] getKeyText() doesn't always return keys.

David "Judah's Shadow" Blue yudahsshadow at gmx.com
Tue Mar 26 13:01:36 EDT 2024


On Monday, March 25, 2024 4:06:19 PM EDT David "Judah's Shadow" Blue wrote:
> On Monday, March 25, 2024 1:52:40 PM EDT David "Judah's Shadow" Blue wrote:
> > I've noticed a problem with lexicons not always getting a value from
> > getKeyText(). It's intermittent, and I can't quite nail down why I would
> > be
> > getting empty strings when I call it sometimes.
> 
> Investigating further, it appears to happen on the first usage of
> getKeyText() but only for lexicon based modules, bibles and commentaries
> show keytext correctly.

In further weirdness, I sometimes get what I have entered previously as the 
key. Here's an example function I use to retrieve a lexicon entry.

std::string Lexicon::getEntry(std::string entry) {
    std::string lexEntry;
    sword::SWModule *module;

    std::transform(entry.begin(), entry.end(), entry.begin(),
                   [](unsigned char c) {return std::toupper(c);});

    
    module = this->swordLibrary->getModule(this->lexiDict.c_str());
    module->setKeyText(entry.c_str());
    
    lexEntry = module->getKeyText();
    lexEntry += " ";
    lexEntry += module->stripText();

    return lexEntry;
}

I am uncertain what I could be doing wrong here.




More information about the sword-devel mailing list