- From: "Alan Garny" <alan.garny AT inria.fr>
- To: <cellml-discussion AT lists.cellml.org>
- Subject: RE: [[cellml-discussion] ] 'loadFromURL' errors
- Date: Tue, 14 Jan 2014 09:46:43 +0100
- Organization: INRIA
Hi Lucian,
>
So, in the past, this code once worked:
>
>
try
>
{
>
model = already_AddRefd<iface::cellml_api::Model>(ml-
>
>loadFromURL(wideFilename.c_str()));
>
}
>
catch (...)
>
{
>
string file(filename);
>
RETURN_INTO_WSTRING(error, ml->lastErrorMessage());
>
string emsg(makeUTF8(error));
>
[...]
>
}
>
>
In other words, it would try to load a model from a URL, and if that
didn't
>
work, would create an error message I could get from 'lastErrorMessage'.
>
>
However, I have now repeatedly run into problems with this code not
actually
>
returning an error message, which ends up creating 'error'
>
with a bad pointer, which then crashes my code when it tries to turn it
back
>
into a real string instead of the wide string.
>
>
Is there any way I can guard against this situation, and/or find a way to
fix the
>
problem?
Which version of the CellML API are you using? I am personally using the
latest snapshot (15 July 2013) and it works fine for me. However, looking at
your code, I can see that you use the 'old' way of doing things. I don't
know whether that 'old' style is still supported, but what is certain is
that, ideally, you wouldn't use already_AddRefd, RETURN_INTO_WSTRING, etc.
anymore. See here
<
https://github.com/opencor/opencor/blob/master/src/plugins/support/CellMLSu
pport/src/cellmlfile.cpp#L163> for how things should now be done.
HTH, Alan.
Archive powered by MHonArc 2.6.18.