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

David "Judah's Shadow" Blue yudahsshadow at gmx.com
Wed Mar 27 16:10:30 EDT 2024


On Tuesday, March 26, 2024 1:01:36 PM EDT David "Judah's Shadow" Blue wrote:
> 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.

I'm still at a loss here. I've tried changing things to where I use a SWKey 
and use setText() there and called setPersist(true) and use that to set the 
module key. All to no avail. getKeyText(); is consistently returning an empty 
string the first time it gets called for a module. The second time it works, 
consistently. Bible texts and commentaries work correctly, genbooks that use 
almost identical code work correctly. I'm not certain what's different about 
lexicons that it doesn't work consistently.




More information about the sword-devel mailing list