John Bandhauer wrote:
> Pass in a JSObject. XPConnect will set a property called 'value' on the
> object hold the 'out' data.
>
> var errStr = {}; // object literal same as 'new Object()'
> if (obj.Open("file.foo", errStr))
> alert(errStr.value);
>
> John.
OK, I tried this out, but I'm still stumped.
In my C++ implementation code, I have:
NS_IMETHODIMP sfGamesetImpl::Open(const char *path, char * *aErrStr,
PRBool *_retval)
{
ofstream fs(DUMP_FILE, ios::out | ios::app);
if (fs)
fs << "sfGameset::Open " << path << endl;
*_retval = false;
if (*aErrStr) {
fs << " freeing aErrStr\n";
PL_strfree(*aErrStr);
*aErrStr = 0;
}
if (PL_strlen(path) > 5) { // Just to test an error return
ostringstream os;
os << "Error: [" << path << "]"; // just so I see it did something intelligent
*aErrStr = PL_strdup(os.str().c_str());
if (fs)
fs << " error: " << *aErrStr << endl;
*_retval = true;
}
return NS_OK;
}
Call obj.Open() from JavaScript crashes Mozilla. Is there something
wrong with my implementation?
- Chuck