diff --git a/modules/libpr0n/src/imgRequest.cpp b/modules/libpr0n/src/imgRequest.cpp index 099847eadb0..70ceee33029 100644 --- a/modules/libpr0n/src/imgRequest.cpp +++ b/modules/libpr0n/src/imgRequest.cpp @@ -36,6 +36,7 @@ #include "nsICachingChannel.h" #include "nsILoadGroup.h" #include "nsIInputStream.h" +#include "nsIMultiPartChannel.h" #include "nsIComponentManager.h" #include "nsIProxyObjectManager.h" @@ -539,7 +540,11 @@ NS_IMETHODIMP imgRequest::OnStartRequest(nsIRequest *aRequest, nsISupports *ctxt open forever. */ if (!mChannel) { - mChannel = do_QueryInterface(aRequest); + nsCOMPtr mpchan(do_QueryInterface(aRequest)); + if (mpchan) + mpchan->GetBaseChannel(getter_AddRefs(mChannel)); + else + mChannel = do_QueryInterface(aRequest); } nsXPIDLCString mContentType; @@ -588,6 +593,12 @@ NS_IMETHODIMP imgRequest::OnStartRequest(nsIRequest *aRequest, nsISupports *ctxt } } + + // Shouldn't we be dead already if this gets hit? Probably multipart/x-mixed-replace... + if (mObservers.Count() == 0) { + this->Cancel(NS_IMAGELIB_ERROR_FAILURE); + } + return NS_OK; } diff --git a/modules/libpr0n/src/imgRequestProxy.cpp b/modules/libpr0n/src/imgRequestProxy.cpp index c5e144b430f..8a509a5d006 100644 --- a/modules/libpr0n/src/imgRequestProxy.cpp +++ b/modules/libpr0n/src/imgRequestProxy.cpp @@ -106,6 +106,7 @@ nsresult imgRequestProxy::Init(imgRequest *request, nsILoadGroup *aLoadGroup, im !(imageStatus & imgIRequest::STATUS_ERROR)) { aLoadGroup->AddRequest(this, cx); mLoadGroup = aLoadGroup; + mIsInLoadGroup = PR_TRUE; } } @@ -361,6 +362,12 @@ void imgRequestProxy::OnStartRequest(nsIRequest *request, nsISupports *ctxt) GetName(getter_Copies(name)); LOG_FUNC_WITH_PARAM(gImgLog, "imgRequestProxy::OnStartRequest", "name", NS_ConvertUCS2toUTF8(name).get()); #endif + + if (!mIsInLoadGroup && mLoadGroup) { + mLoadGroup->AddRequest(this, mContext); + mIsInLoadGroup = PR_TRUE; + } + } void imgRequestProxy::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult statusCode) @@ -383,6 +390,6 @@ void imgRequestProxy::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsre nsCOMPtr kungFuDeathGrip(this); mLoadGroup->RemoveRequest(this, mContext, statusCode); - mLoadGroup = nsnull; + mIsInLoadGroup = PR_FALSE; } diff --git a/modules/libpr0n/src/imgRequestProxy.h b/modules/libpr0n/src/imgRequestProxy.h index 7584244ae53..234803598c4 100644 --- a/modules/libpr0n/src/imgRequestProxy.h +++ b/modules/libpr0n/src/imgRequestProxy.h @@ -87,7 +87,8 @@ private: nsCOMPtr mLoadGroup; nsLoadFlags mLoadFlags; - PRBool mCanceled; + PRPackedBool mCanceled; + PRPackedBool mIsInLoadGroup; PRLock *mLock; };