Re: Crash when getting module type

"David \"Judah's Shadow\" Blue" <[email protected]>
Newsgroups gmane.comp.literature.sword.devel
Message-ID <4843586.GXAFRqVoOG@brooks>
On Sunday, October 29, 2023 2:21:12 PM EDT Troy A. Griffitts wrote:
> Hi David,
>
> On October 29, 2023 10:52:50 MST, "David "Judah's Shadow" Blue"
<[email protected]> wrote:
> >The next class at play is the library class that also has a private member
> >swordLibrary,
> >
> >sword::SWMgr swordLibrary;
>
> This is the issue. Since you are declaring an instance of SWMgr here, it
> will get constructed in your library class c-tor with its own set of module
> and filter, etc. objects. Then in setSwordLibrary you assign that fully
> constructed local instance to a reference to the instance you newed
> outside.
> SWMgr is a factory object and assigning one factory to another doesn't
> equate to a clear action. We could set option values from the source to the
> destination, I suppose, but still that would give you what you want. I
> would suggest changing this swordLibrary property of your library class to
> a pointer. Then things should work as you expect.

That all makes senese. I've changed it to be a pointer in my interface class,
so now it've got, my initialize 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;
}

And in my Library class, I've got a private member

sword::SWMgr *swordLibrary;

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

But I'm still getting a crash in the same spot once I try to get a module
type, so I'm sure I've done something else wrong but am not sure what.

_______________________________________________
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/rk8ACgkQx/nqiX8H
6VBbSg/+IBv23LKoryXBfzL1RLfRa6KxBwS0MvX73kmycUQa5I8w5NMaERUl8Od0
bJtdc5uJ7HDnXBiKHBGYQAEWJbHMpc0U9iZwOwzXhPKvPVSlr5LVhxljtyviuoY9
+9CQXxOwUTXu1KWuz2SQGUK6msxh/meSPtEjpgfE9gxYlpoADiq2o7oUcrenRjjW
eqtSEWwjkziMBko2X80SOXPMfAvtL9+UskhpZ8CecMxs1VtuevVjvGn7NV3KuHBo
whWVKhtNuiER1kBdqwlr4XRJvKCnRkN4akWyVH4UU0VlELQetKwsDTfi9hayrbQR
x7G8NgTsPGrkD/sdJYGWZjsAj2g+rk5XFt8/869pTLEPUmlkvxtE/OBK3QJ7LqPA
mqQ0Y22sWkphMOAzb6zHoUoMnyvtRT5ecUHmRdKZYviF/6EzMnl61iiMUuokAAKW
tA7vWOIjx/I5t74Arsyw4xS09I7dRJ7hbFhj2f0IFDNoW82blW4KkLm+wc5IL1Oi
LPYEisfUK2oC84TWGhUPY36ntonVMKEqkZCfQMdSR50ftKTPrRZ8nDt+07eBxmor
EFKZGt8gy2VzzyE4a2JjoMSNb5/UahuX1ANcsiNjF/Y6AqJvnuQk22aHmv/QAC0d
n4WxPeqhug9R7MrXABWAxSNi9EFDTpwYyJx9OqdFrhabDVhOwdk=
=m9VK
-----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.