зеркало из https://github.com/mozilla/gecko-dev.git
Bug 802390 - Gracefully handle shutting down a decoder that hasn't had a chance to do any work. r=jrmuizel
This commit is contained in:
Родитель
5748e6d4d9
Коммит
9775b3728a
|
@ -100,7 +100,7 @@ Decoder::Finish()
|
||||||
nsCOMPtr<nsIScriptError> errorObject =
|
nsCOMPtr<nsIScriptError> errorObject =
|
||||||
do_CreateInstance(NS_SCRIPTERROR_CONTRACTID);
|
do_CreateInstance(NS_SCRIPTERROR_CONTRACTID);
|
||||||
|
|
||||||
if (consoleService && errorObject && !HasDecoderError()) {
|
if (consoleService && errorObject && HasDataError() && !HasDecoderError()) {
|
||||||
nsAutoString msg(NS_LITERAL_STRING("Image corrupt or truncated: ") +
|
nsAutoString msg(NS_LITERAL_STRING("Image corrupt or truncated: ") +
|
||||||
NS_ConvertASCIItoUTF16(mImage.GetURIString()));
|
NS_ConvertASCIItoUTF16(mImage.GetURIString()));
|
||||||
|
|
||||||
|
@ -114,16 +114,22 @@ Decoder::Finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we only have a data error, see if things are worth salvaging
|
bool usable = true;
|
||||||
bool salvage = !HasDecoderError() && mImage.GetNumFrames();
|
if (HasDataError() && !HasDecoderError()) {
|
||||||
|
// If we only have a data error, we're usable if we have at least one frame.
|
||||||
|
if (mImage.GetNumFrames() == 0) {
|
||||||
|
usable = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If we're salvaging, say we finished decoding
|
// If we're usable, do exactly what we should have when the decoder
|
||||||
if (salvage)
|
// completed.
|
||||||
mImage.DecodingComplete();
|
if (usable) {
|
||||||
|
PostDecodeDone();
|
||||||
// Fire teardown notifications
|
} else {
|
||||||
if (mObserver) {
|
if (mObserver) {
|
||||||
mObserver->OnStopDecode(salvage ? NS_OK : NS_ERROR_FAILURE);
|
mObserver->OnStopDecode(NS_ERROR_FAILURE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче