Bug 932025: Don't use Maybe<AutoCompartment> in OldDebugAPI.cpp, to avoid dumb G++ warnings. r=sfink

This commit is contained in:
Jim Blandy 2013-10-28 15:45:58 -07:00
parent 8c189cbe06
commit 01e68ba41d

View File

@ -1029,11 +1029,19 @@ FormatValue(JSContext *cx, const Value &vArg, JSAutoByteString &bytes)
{
RootedValue v(cx, vArg);
mozilla::Maybe<AutoCompartment> ac;
if (v.isObject())
ac.construct(cx, &v.toObject());
/*
* We could use Maybe<AutoCompartment> here, but G++ can't quite follow
* that, and warns about uninitialized members being used in the
* destructor.
*/
RootedString str(cx);
if (v.isObject()) {
AutoCompartment ac(cx, &v.toObject());
str = ToString<CanGC>(cx, v);
} else {
str = ToString<CanGC>(cx, v);
}
JSString *str = ToString<CanGC>(cx, v);
if (!str)
return nullptr;
const char *buf = bytes.encodeLatin1(cx, str);