Re: Crash when getting module type

"David \"Judah's Shadow\" Blue" <[email protected]>
Newsgroups gmane.comp.literature.sword.devel
Message-ID <12311524.O9o76ZdvQC@brooks>
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
between.

> 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() {
    configScreen();

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

    library.setSwordLibrary(*swordLibrary);
    library.passage.setLibrary(*swordLibrary);
    library.lexicon.setSwordLibrary(*swordLibrary);

    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
swordLibrary,

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";
            moduleList.push_back(module);
            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();
            moduleList.push_front(module);
            module = "";
        }
    }

    return moduleList;

}

_______________________________________________
sword-devel mailing list: [email protected]
http://crosswire.org/mailman/listinfo/sword-devel
Instructions to unsubscribe/change your settings at above page
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEE2HjGsPT4oPc9mpWEx/nqiX8H6VAFAmU+m/IACgkQx/nqiX8H
6VCx+w//QgrWz6IHsPx8DTcB7MMDd58HpU5P6vbiUkicWGQSS0T8n3suTsMXcZy7
7c1pRh1eoBaYuqYqr9K/QEnEzORZrZJy4K5gySj1DS1EgBtb9I5Af4nkoZUKlL+D
py3fKdeH3brVcY9KClOPYn0o/YgdmDBvqgY4DCmvV/Xt20aNR6moZL/uR3XnSUOV
8r8r+JMpFY/2GaA+/aWtx9aTGVU2Otk8QJO5Y92RJWyJxGhn4ykcmkKY9aWLOSAX
ARbOJbbsKLKzYSYXrH40TKZ/nEOpFOmWZDHZCe6nSrlvGY8nL1zRJsx904sCRAUE
GRd0+S808/6cFX/n61x2wCN0GQZrWwHnFrClqZ47oWqoj8ZdyrnJp/OJxFZnMD0a
1ABKZgn/IPYj513mDXhqy76iYwX2l5X5eeH9MoEh1Lr3Xd6V9bjRLon3a5BIMbUe
BvIhJLyEhRnX+lfwStS2ep0W/ZH3d7Wc9JxD7N8uLh7z0nUvExB2pxwSvt+2uYXc
V6CajglOlPKc+wwIA7Ysf1yOxWFpWmBj//Q1hIf3Oli66IIpQB7qKC2FTcsEXMBV
OYostoFKp6psWsKuv0lkjYIStYQWdwLtaGpyp01gmWoBfMSAHY0wZ6Q22PHkZO5K
28fkUmeESEES2McBqaT3KPYC4rUpJyS6Y02WlKlIQUq5T4X0QDY=
=LhLd
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.