diff --git a/suite/common/directory/directory.js b/suite/common/directory/directory.js index 4f5b58ba5c2..26c37edf913 100644 --- a/suite/common/directory/directory.js +++ b/suite/common/directory/directory.js @@ -135,7 +135,9 @@ function ReadDirectory(url) var uri = ios.newURI(url, null); // Create a channel... - var channel = ios.newChannelFromURI('load', uri, null, null, Components.interfaces.nsIChannel.LOAD_NORMAL, null); + var channel = ios.newChannelFromURI('load', uri, null, null, + Components.interfaces.nsIChannel.LOAD_NORMAL, + null, 0, 0); // ...so that we can pipe it into a new HTTPIndex listener to // parse the directory's contents. diff --git a/xpfe/components/directory/directory.js b/xpfe/components/directory/directory.js index 4f5b58ba5c2..26c37edf913 100644 --- a/xpfe/components/directory/directory.js +++ b/xpfe/components/directory/directory.js @@ -135,7 +135,9 @@ function ReadDirectory(url) var uri = ios.newURI(url, null); // Create a channel... - var channel = ios.newChannelFromURI('load', uri, null, null, Components.interfaces.nsIChannel.LOAD_NORMAL, null); + var channel = ios.newChannelFromURI('load', uri, null, null, + Components.interfaces.nsIChannel.LOAD_NORMAL, + null, 0, 0); // ...so that we can pipe it into a new HTTPIndex listener to // parse the directory's contents. diff --git a/xpfe/components/directory/nsDirectoryViewer.cpp b/xpfe/components/directory/nsDirectoryViewer.cpp index edb105a6b1b..94b05f4577c 100644 --- a/xpfe/components/directory/nsDirectoryViewer.cpp +++ b/xpfe/components/directory/nsDirectoryViewer.cpp @@ -321,55 +321,57 @@ nsHTTPIndexParser::OnStartRequest(nsIChannel* aChannel, nsISupports* aContext) { nsresult rv; - // We need to undo the AddRef() on the nsHTTPIndex object that - // happened in nsDirectoryViewerFactory::CreateInstance(). We'll - // stuff it into an nsCOMPtr (because we _know_ it'll get release - // if any errors occur)... - nsCOMPtr httpindex = do_QueryInterface(mHTTPIndex); + // This should only run once... + if (mContainer) { + // We need to undo the AddRef() on the nsHTTPIndex object that + // happened in nsDirectoryViewerFactory::CreateInstance(). We'll + // stuff it into an nsCOMPtr (because we _know_ it'll get release + // if any errors occur)... + nsCOMPtr httpindex = do_QueryInterface(mHTTPIndex); - // ...and then _force_ a release here - mHTTPIndex->Release(); + // ...and then _force_ a release here + mHTTPIndex->Release(); - // Now get the content viewer container's script object. - nsCOMPtr scriptGlobal(do_GetInterface(mContainer)); - NS_ENSURE_TRUE(scriptGlobal, NS_ERROR_FAILURE); + // Now get the content viewer container's script object. + nsCOMPtr scriptGlobal(do_GetInterface(mContainer)); + NS_ENSURE_TRUE(scriptGlobal, NS_ERROR_FAILURE); - nsCOMPtr context; - rv = scriptGlobal->GetContext(getter_AddRefs(context)); - NS_ENSURE_TRUE(context, NS_ERROR_FAILURE); + nsCOMPtr context; + rv = scriptGlobal->GetContext(getter_AddRefs(context)); + NS_ENSURE_TRUE(context, NS_ERROR_FAILURE); - JSContext* jscontext = NS_REINTERPRET_CAST(JSContext*, context->GetNativeContext()); + JSContext* jscontext = NS_REINTERPRET_CAST(JSContext*, context->GetNativeContext()); - // Using XPConnect, wrap the HTTP index object... - static NS_DEFINE_CID(kXPConnectCID, NS_XPCONNECT_CID); - NS_WITH_SERVICE(nsIXPConnect, xpc, kXPConnectCID, &rv); - if (NS_FAILED(rv)) return rv; + // Using XPConnect, wrap the HTTP index object... + static NS_DEFINE_CID(kXPConnectCID, NS_XPCONNECT_CID); + NS_WITH_SERVICE(nsIXPConnect, xpc, kXPConnectCID, &rv); + if (NS_FAILED(rv)) return rv; - nsCOMPtr wrapper; - rv = xpc->WrapNative(jscontext, - httpindex, - nsCOMTypeInfo::GetIID(), - getter_AddRefs(wrapper)); + nsCOMPtr wrapper; + rv = xpc->WrapNative(jscontext, + httpindex, + nsCOMTypeInfo::GetIID(), + getter_AddRefs(wrapper)); - NS_ASSERTION(NS_SUCCEEDED(rv), "unable to xpconnect-wrap http-index"); - if (NS_FAILED(rv)) return rv; + NS_ASSERTION(NS_SUCCEEDED(rv), "unable to xpconnect-wrap http-index"); + if (NS_FAILED(rv)) return rv; - JSObject* jsobj; - rv = wrapper->GetJSObject(&jsobj); - NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get jsobj from xpconnect wrapper"); - if (NS_FAILED(rv)) return rv; + JSObject* jsobj; + rv = wrapper->GetJSObject(&jsobj); + NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get jsobj from xpconnect wrapper"); + if (NS_FAILED(rv)) return rv; - jsval jslistener = OBJECT_TO_JSVAL(jsobj); + jsval jslistener = OBJECT_TO_JSVAL(jsobj); - // ...and stuff it into the global context - PRBool ok; - JSObject* global = JS_GetGlobalObject(jscontext); - ok = JS_SetProperty(jscontext, global, "HTTPIndex", &jslistener); + // ...and stuff it into the global context + PRBool ok; + JSObject* global = JS_GetGlobalObject(jscontext); + ok = JS_SetProperty(jscontext, global, "HTTPIndex", &jslistener); - NS_ASSERTION(ok, "unable to set Listener property"); - if (! ok) - return NS_ERROR_FAILURE; - + NS_ASSERTION(ok, "unable to set Listener property"); + if (! ok) + return NS_ERROR_FAILURE; + } // Save off some information about the stream we're about to parse. rv = aChannel->GetURI(getter_AddRefs(mDirectoryURI));