On Friday, October 27, 2023 1:25:44 PM EDT Troy A. Griffitts wrote:
> I don't believe the issue is between when you declare the tempMod
> variable and when you assign it.
> I believe the issue is between when you construct SWMgr() and when you
> get to your code block.  Somebody has done something strange with SWMgr
> before you get to your code block.

That is possible, I do pass the pointer to my SWMgr around a bit.

> If you give more context, I can have a look.  Another thing you can try
> is to simply to create 'swordLibrary' just before your `for` loop block
> to be sure nothing has gone wrong someplace else.

Creating a new instance of SWMgr works as expected, so something is happening

> But to help you debug, I'd need to see a block of code that doesn't work
> which also contains your construction of 'swordLibrary' and everything
> between that construction and the `for` loop you've posted.

Ok. Let me see what I can do.

First,  I have a couple of classes at play. The interface class which houses
the initial swordLibrary declared as a Private member

sword::SWMgr *swordLibrary;

I instantiate the library in the initialize (non-constructor) method.

void Interface::initalize() {

    std::cout  << "Initializing SWORD, please wait..." << std::endl;
    this->swordLibrary = new sword::SWMgr(new


    std::cout << "Initialized, proceeding to shell..." << std::endl;

Then, things pass off to my various methods that run the interface, but don't
touch the sword library (or at least shouldn't)

The next class at play is the library class that also has a private member

sword::SWMgr swordLibrary;

and a setSwordLibrary(), method,

void Library::setSwordLibrary(sword::SWMgr &library) {
    this->swordLibrary = library;

it also has the method in question getModuleList,

std::list< std::string > Library::getModuleList(std::string moduleType) {
    std::string module = "";
    sword::ModMap::iterator libraryIterator;
    std::list<std::string> moduleList;
    std::string selectedType;
    std::string modType;

    std::string bible = sword::SWMgr::MODTYPE_BIBLES;
    std::string comentary = sword::SWMgr::MODTYPE_COMMENTARIES;
    std::string devo = sword::SWMgr::MODTYPE_DAILYDEVOS;
    std::string book = sword::SWMgr::MODTYPE_GENBOOKS;
    std::string dict = sword::SWMgr::MODTYPE_LEXDICTS;

    if(moduleType == "bible") {
        selectedType = bible;
    else if(moduleType == "commentary") {
        selectedType = comentary;
    else if(moduleType == "devotion") {
            selectedType = devo;
    else if(moduleType == "book") {
            selectedType = book;
    else if(moduleType == "dictionary") {
            selectedType = dict;
    else {
            //We should never get here but you never know.
            module = "Invalid type";
            return moduleList;

    for(libraryIterator = this->swordLibrary.Modules.begin();
        libraryIterator != this->swordLibrary.Modules.end();
        libraryIterator++) {

        sword::SWModule *tempMod = libraryIterator->second;

        modType = tempMod->getType();

        if(modType == selectedType) {
            module = "For ";
            module += tempMod->getDescription();
            module += " select ";
            module += tempMod->getName();
            module = "";

    return moduleList;


Attachment: signature.asc
Description: This is a digitally signed message part.

sword-devel mailing list: sword-devel@crosswire.org
Instructions to unsubscribe/change your settings at above page

Reply via email to