From 8536bd9ae66ec79efe92dd9c22be80cd3a6940e8 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Tue, 2 Jul 2013 14:39:02 -0600 Subject: [PATCH] Bug 888104 - Move nsCxPusher's mScx grabbing code into the common helper method. r=gabor This function is called by Push and PushNull, so with the added null check this is equivalent. This facilitates the refactoring in the next patch. --- js/xpconnect/src/nsCxPusher.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/js/xpconnect/src/nsCxPusher.cpp b/js/xpconnect/src/nsCxPusher.cpp index da356221482..4cbcb868b7f 100644 --- a/js/xpconnect/src/nsCxPusher.cpp +++ b/js/xpconnect/src/nsCxPusher.cpp @@ -106,17 +106,18 @@ nsCxPusher::Push(JSContext *cx) MOZ_ASSERT(!mPushedSomething, "No double pushing with nsCxPusher::Push()!"); MOZ_ASSERT(cx); - // Hold a strong ref to the nsIScriptContext, just in case - // XXXbz do we really need to? If we don't get one of these in Pop(), is - // that really a problem? Or do we need to do this to effectively root |cx|? - mScx = GetScriptContextFromJSContext(cx); - DoPush(cx); } void nsCxPusher::DoPush(JSContext* cx) { + // If we have a cx, hold a strong ref to the nsIScriptContext, just in case. + // XXXbz do we really need to? If we don't get one of these in Pop(), is + // that really a problem? Or do we need to do this to effectively root |cx|? + if (cx) + mScx = GetScriptContextFromJSContext(cx); + // NB: The GetDynamicScriptContext is historical and might not be sane. if (cx && nsJSUtils::GetDynamicScriptContext(cx) && xpc::IsJSContextOnStack(cx))