[sword-devel] Finding Devotional modules

David "Judah's Shadow" Blue yudahsshadow at gmx.com
Tue Mar 19 15:42:16 EDT 2024


On Monday, March 18, 2024 2:21:40 PM EDT David "Judah's Shadow" Blue wrote:
> On Tuesday, March 12, 2024 4:31:07 PM EDT David "Judah's Shadow" Blue wrote:
> > After grepping around in the BibleTime source code, I settled on using
> > their solution of using module category and/or features showing the
> > module is a devotional. I'm doing the following assignment
> > 
> > category = tempMod->getConfigEntry("Category");
> > 
> > If category is a std::string I get a segfault. If category is a const
> > char*
> > it works. Is there some reason the return value of getConfigEntry isn't
> > compatible with std::string in this instance? Or have I found a magic/more
> > magic switch?
> 
> Based on other weirdness I get from this function, I want to say it's a
> magic/ more magic switch. That said, I would really like to declare
> category as a std::string instead of a const char* so I can do a straight
> literal comparison instead of mucking around with strncmp (which at the
> moment is also crashing). For devotionals, maps, and image based modules I
> can fall back to
> getConfig.has("Feature",feature). But I don't have such a fallback for "Cult
> / Unorthodox / Questionable Material" category works, which is what I'm
> currently trying to filter out. I've included my function as it stands
> currently using const char* and strncmp.

I don't understand the other weirdness I was getting (debug messages only 
showing once or not at all in a loop if they were on std::cerr, but behaving 
correctly on std::cout), but I did track the source of the crashes with using 
a std::string to store the results of getConfigEntry(). Turns out, if there is 
no category field for a module, getConfigEntry() returns a NULL pointer, so a 
quick NULL check and all was happy again.




More information about the sword-devel mailing list